On Mon, 18 Mar 2002, James Strachan wrote:
> ----- Original Message -----
> From: "Morgan Delagrange" <[EMAIL PROTECTED]>
> > > yeah, I think I did mean ArrayIterator.  The simple way of doing this
> > > would be to use Array.getLength(array).  That does the checking for you.
> > > It also lets you calculate the length once (in the constructor) so that
> > > multiple calls to hasNext does not require the overhead of
> > > Array.getLength(...).
> >
> > OK, sounds reasonable.  FWIW, it may make sense to optimize this class
> > someday, so we don't perform unnecessary reflection on Object[] arrays.
> 
> Though I didn't think you could cast all arrays to Object[] so I'd prefer to
> keep the reflection based implementation - I've certainly written code
> before that needs it. e.g.
> 
> int[] foo = {1,2,3};
> Object[] bar = (Object[]) foo;
> 
> The above is invalid.

I think what Morgan was referring to was possibly optimizing when this 
*is* possible.  E.g. have a second constructor that takes an Object[].  
That way, if the object past in *is* castable as Object[], then a 
non-reflection based impl could be used.  I'm not sure how the two impls 
could be mixed though, so I'm not sure how much of an optimization it 
really is.  

I think we both recognize that taking an int[] should be allowed.

regards,
michael


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to