Stephen,

Have you any tests to prove there is actually a performance gain? Surely either (or both) the java compiler or the JVM should be responsible for optimizations such as this.

Gareth.

Stephen Colebourne wrote:

From: "Brian McCallister" <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]







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



Reply via email to