commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] [PATCH] CompositeCollection class for Commons-Collections
Date Wed, 05 Nov 2003 22:54:33 GMT
From: "Brian McCallister" <mccallister@forthillcompany.com>
On Monday, November 3, 2003, at 07:48 PM, Stephen Colebourne wrote:
> > I've updated the class in line with commons standards/documentation
> > etc. It
> > will probably end up in the decorators subpackage, as it decorates
> > other
> > collections.
>
> A few style questions about this...
>
> You have changed the array traversal to use the form:
>
>      public int size() {
>          int size = 0;
>          for (int i = this.all.length - 1; i >= 0 ; i--) {
>              size += this.all[i].size();
>          }
>          return size;
>      }

> Do you really see a performance gain from not dereferencing
> this.all.length on each cycle? If so, cool stuff!

Yes, you gain from not having to check the variable all and its length. You
also gain from the comparision to 0 (i>=0) which is quicker than a non-zero
comparison (i  < n). Some methods required to keep the order, so I have been
selective.

Stephen




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message