> -----Original Message-----
> From: Finn Bock [mailto:[EMAIL PROTECTED]

> [ Glen : ]
> > Sigh...I guess I *didn't* know bytecode by heart after
> > all!  ;-)
> I didn't bring it up to discourage the use of static initialized arrays.
> If it makes sense to put something in a static array we should do so
> without concern of compiletime vs. runtime. After all, the
> initialization is only performed once per classloader.

Well, (sorry to disappoint you, Peter) I don't know my BC by heart, but IIRC
the real difference would be in the size of the compiled classes...
See also a little trick I stumbled upon for for-loops. It's common(?)
knowledge that testing for a value to be greater than (or equal to) another
value, is the same as testing whether the result of their subtraction is
greater than (or equal to) zero --rewriting this effectively saves a
processor instruction per comparison.
If you subsequently combine the test and the decrementing of the counter,
you can slightly reduce the size of the compiled class further.

In short:

  for( int i = 0; i < j ; ++i )

is better written as ( = faster; that is: it will save a few hundred
millisecs in large loops, the few that might just be enough to give the
average user the impression that the software is actually any faster than
before )

  for( int i = j; i > 0; --i )

and even better ( leads to even more compact compiled classes;
performance-boost is negligeable with current hardware, but might turn out
to be an advantage --albeit a minor one - when this class has to be loaded
from a network location )

  for( int i = j; --i >= 0; )



Reply via email to