(original) (raw)

On Feb 14, 2014, at 10:54 AM, Krystal Mok <rednaxelafx@gmail.com> wrote:

There's no dominating check on elements.length, so a range check will still have to be generated in this case. Simplifying the check to (elements.length != 0) or (elements.length u> 0) doesn't really buy much, because the final index is calculated and put into a register already anyway, doing the normal (index u< elements.length) check before this patch should be just as fast.

I think there is a small benefit to simplifying the range check to a test against zero:  It reduces the use count of "head" (possible register pressure effect) and the number of inputs to the test (possible scheduling effect, including runtime hardware micro-ops).

But the case of HashMap is better, since we can piggy-back the reduced range check on top of the pre-existing empty-table check.

� John