$10K coding deathmatch
Bryan Sant
bryan.sant at gmail.com
Fri Nov 3 15:03:29 MST 2006
On 11/3/06, Barry Roberts <blr at robertsr.us> wrote:
> Java start-up time is big enough you're never gonna win the 5-line
> test, but I can't resist suggesting this short-ciruit optimzation to
> see how much difference it makes, since all the others do it.
>
> Change:
> for (int i = 0; i < len; i++) {
> to:
> for (int i = 0; i < len && !match; i++) {
>
>
> Barry
My bad. The benchmarked code was doing a short-circuit on the loop.
It actually had:
if (diff > len || diff == 0) {
match == false;
break;
}
Which does the same thing. I like your code better though.
-Bryan
More information about the PLUG
mailing list