Remove the assert in Integer.valueOf() (original) (raw)

Ulf Zibis Ulf.Zibis at gmx.de
Fri Apr 27 12:14:10 UTC 2012


Am 23.04.2012 19:35, schrieb Rémi Forax:

Hi guys, I've found a case where assert is harmful because it doesn't play well with Hotspot inlining heuristic. [...] I think it's a good idea to comment this assert.

While you are there: IntegerCache.cache/high/low are static final, so should be named upper case.

Another optimization: public static Integer valueOf(int i) { if (i >= 0) { if (i <= IntegerCache.HIGH) return IntegerCache.POS[i]; } else { if (i >= IntegerCache.LOW) return IntegerCache.NEG[~i]; } return new Integer(i); }

-Ulf



More information about the core-libs-dev mailing list