On Fri, Mar 12, 2010 at 05:04, Ulf Zibis <[email protected]> wrote: > Am 12.03.2010 02:46, schrieb Martin Buchholz: > public static boolean isISOControl(int codePoint) { > // Optimized form of: > // (codePoint >= 0x0000 && codePoint <= 0x001F) || > // (codePoint >= 0x007F && codePoint <= 0x009F); > return codePoint <= 0x009F && > (codePoint >= 0x007F || (codePoint >>> 5 == 0)); > } > > Because non-ASCII chars get away with only one comparison. > > > +1 thanks. > Because here we are talking about ASCII values, I would prefer 2-digit > values or complete code points e.g. 0x0000007F.
Good idea. Done. > > Alright, you've talked me into it, > I can't resist your love of micro-optimizations. > > > Is that sentence correct english grammar? I'm afraid to misunderstand. , ==> . > By the way, I've filed some bugs against HotSpot to optimize those cases: > 6932837 - Better use unsigned jump if one of the range limits is 0 > 6932855 - Save superfluous CMP instruction from while loop > 6933327 - Use shifted addressing modes instead of shift instuctions > 6933324 - Always inline methods, which have only 1 call site > > If they would be accepted and fixed, some of our twiddling would become > superfluous, at least using c2, but maybe not for interpreter and c1. Of course, we often write hotspot-optimized code, but in general we should try to write "good" code that any VM could love. Martin
