> Speaking of bounds checking, I understand that in at least some JVMs,
> it'd be even faster to write code like:
>
> try
> {
> byte[] vgaBuffer = jos.system.machine.getBytes(0xa0000, 0x10000);
> int i = 0;
> while (true)
> vgaBuffer[i++] = 0;
> }
> catch (ArrayIndexOutOfBoundsException aioobe)
> {
> }
>
> basically, don't bother explicitly checking the value of i (like the
> "for" loop does) since the JVM will be checking it itself anyhow.
I have to comment on this one.
Please, please, please... don't do that..
Don't!
You will make life much harder for an optimizing compiler.
Constant ranged loops can easily be optimized
(bounds checking removed, loopunrolling, etc.).
Please, don't rely on Exception-handling mechanism to handle cases that
are quite common. Exception handlers should handle exceptions from the
ordinary,
things that may take long time.
Joakim Dahlstedt
_______________________________________________
Kernel maillist - [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel