(original) (raw)
It's totally reasonable, and is already filed as an RFE (please comment on it!):� John
On Feb 12, 2014, at 9:40 AM, Martin Grajcar <maaartinus@gmail.com> wrote:
Most hash tables are power-of-two sized so that they can use masking for the access. It looks like the bounds check doesn't get eliminated, although it could be.Based on the equivalencea\[x & (a.length - 1)\]
throws if and only ifa.length == 0
, I'm proposing this simple algorithm:
- For each array access, check if the index has been computed via a bitwise and.
- If so, check if either of the operands was computed as length minus one.
- If so, replace the bounds check by a zero-length check.
This zero-length check can then be easily moved out of the loop by the existing optimizations.I hope I'm not talking non-sense. For more details seeRegards,Martin.