Thanks Zhong, you are correct.
So we additionally can save again 1 variable and 2 lines.

-Ulf

Am 09.10.2012 23:08, schrieb Zhong Yu:
Ulf, since

     allUpper  <==>  ca==null

we don't need allUpper...

On Tue, Oct 9, 2012 at 2:31 PM, Ulf Zibis <ulf.zi...@cosoco.de> wrote:
Hi,

I did not look into the details, but the hint about performance on
String.toLower in WindowsNTFileSystem catched my attention. Here is a very
fast converter, which may be enough for calculating the hash:

     // Private ASCII-only optimized version
     public static final String toUpper(final String s) {
         boolean allUpper = true;
         char[] ca = null;
         for (int i=0; i<s.length(); i++) {
             int c = s.charAt(i);
             if (c >= 'a' && c <= 'z') {
                 if (allUpper) {
                     ca = s.toCharArray();
                     allUpper = false;
                 }
                 ca[i] -= '\u0020';
             }
         }
         return allUpper ? s : new String(ca);
     }

It also avoids instantiation of new objects, if there is nothing to change.
Note: the equivalent toLower algorithm statistically would be little slower
on latin characters, but maybe faster on wide spreaded Unicode characters.

-Ulf


Am 09.10.2012 19:46, schrieb Dan Xu:
Hi folks,

Please help review the code change for CR7186817 to remove Windows
95/98/ME support. The webrev has been uploaded to
http://cr.openjdk.java.net/~dxu/7186817/webrev/
<http://cr.openjdk.java.net/%7Edxu/7186817/webrev/>

The main focus of this clean-up is in IO area. And I also cleaned
java/lang/ProcessImpl_md.c and java/util/TimeZone_md.c in this transaction.

Thanks,

-Dan


Reply via email to