Am 24.03.2010 08:32, schrieb Martin Buchholz:
Hi Ulf,
You have this interesting optimization:
public static boolean isSurrogate(char ch) {
- return ch>= MIN_SURROGATE&& ch< MAX_SURROGATE + 1;
+ return (ch -= MIN_SURROGATE)>= 0&& ch< MAX_SURROGATE + 1 -
MIN_SURROGATE;
}
Do you have any evidence that hotspot can produce better code from this,
or that there is a measurable performance improvement?
Or was this just an experiment?
If isHighSurrogate and isSurrogate are used consecutive on same char,
result of ch -= MIN_SURROGATE could be used for both.
If isLowSurrogate and isSurrogate are used consecutive on same char,
result of ch -= MAX_SURROGATE would fit better.
If isHighSurrogate and isLowSurrogate are used consecutive on same char,
result of ch -= MIN_LOW_SURROGATE would fit better.
I suggest using 1st pair in JDK library.
-Ulf