----- Original Message -----
From: "James Strachan" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
Sent: Monday, March 18, 2002 5:45 PM
Subject: Re: [COLLECTIONS] [VOTE] Release Collections 2.0


> ----- 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.
>
> James
>

I was thinking more along the lines of:

  if (array instanceof Object[]) {
      // don't use reflections
  } else {
      // use reflection
  }

Reflection is cheaper then it used to be, but it's still a bit pricey.

- Morgan


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to