<snip/>

> > So the first recommendation is to use String "+" for this type of
> > method, it's easier to read and runs faster.
> [ SNIP ]
> 
> This kind of thing is discussed by Jack Shirazi at length, also.
> 
> The thing is, there has long been a blanket instruction, don't use String
> concatenation. Programmers learn it by fiat, and never think it through. In
> fact, it should be obvious to any programmer (if they are encouraged to
> think, that is) that concatenation of literal Strings is not something to
> avoid. Assuming a decent compiler.

You've hit the nail on the head. Optimizations are just that
optimizations. They are not "blanket application" things.

Like anybody else there are times when I optimize as I go, but I really
try and keep in mind, "is this the simplest thing I could do?" Fighting
the urge to apply "optimizations" as you go is hard sometimes but in my
experience leads to a better code base.

When you do apply an optimization, prove it's worth. Create a small set
of tests that show the difference and try and run them on a number of
vms.

You'd be surprised at the things I've found, on one embedded vm  

x = (y == null) ? a : b;

was 50% slower than

if (y == null)
        x = a;
else
        x = b;

go figure.

-k.


-- 
If you don't test then your code is only a collection of bugs which 
apparently behave like a working program. 

Website: http://www.rocketred.com.au/blogs/kevin/


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

Reply via email to