See the email log for more information from the customer.
A DESCRIPTION OF THE REQUEST :
String.toLowerCase() has a huge performance regression in JDK 1.5.0_x
toLowerCase() iternally uses String.intern() on the Local's language, presumably to avoid needing to use String.equals() for comparison on some strings of length nomore than 2. This use of intern() is a performance desaster. [If you are curious check out the native JDK source code for String.intern(), and see how it oscillates multiple times between native code and java code, only to end up using a plain vanilla HashMap on the Java heap for its interned Strings.]
JUSTIFICATION :
Try running some heavy string tokenization codes involving String.toLowerCase for case insensitivity, or simple a loop that does many millions of toLowerCase calls. The JDK 1.5 profiler shows that 80% of the time is spent in String.intern(), which is called by String.toLowerCase()
This is unacceptable, in particular since the JDK 1.4.x line never had this problem.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The fix is to revert to using equals for comparison the Locale's language, or even better have the Locale or default Locale intern the language (the assumption is that Locale's are infrequently constructed).
ACTUAL -
see problem description
---------- BEGIN SOURCE ----------
class test
{
public static void main(String[] args)
{
String s = "";
long stime = System.currentTimeMillis();
for (int i=0; i < 1000; i++) {
s += "hello + i".toLowerCase();
}
System.out.println("time = "+(System.currentTimeMillis()-stime));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See expected behaviour
###@###.### 2005-05-05 10:30:14 GMT