Am 15.05.2009 00:03, Xueming Shen schrieb:

What is the "XOR approach"? I might have miss it. I'm happy to try it out. OK, the "3 times computing" and "compare <0" are the good hint to improve, the
latest one looks like

I'm afraid, you really missed it. See my post from 12.05.2009 20:25 CEST ;-)
I mean:

          int cnsPlane = sa[sp +1] ^ 0xa0;
          if (cnsPlane > 0xf || (cnsPlane = cnspToIndex[cnsPlane]) < 0)
              return CoderResult.malformedForLength(2);

or maybe (to force LoadUB (Bug ID 6797305), which may be faster than sign extension to int):
          int cnsPlane = (sa[sp +1] ^ 0xa0) && 0xff;

or maybe use byte[] (to force LoadUB, which may be faster than sign extension to int):
          byte cnsPlane = (byte)(sa[sp +1] ^ 0xa0);
or
byte cnsPlane = (byte)((sa[sp +1] && 0xff) ^ (0xa0 && 0xff)); // don't know if this make a difference

But anyway, I think,
      static final byte[] cnspToIndex = new byte[0x100];
      ...

would be the fastest.


180                         int cnsPlane = sa[sp +1];

I guess this is worse, but definitely not better, than
       int cnsPlane = sa[sp +1] & 0xff;

Reason:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6797305

181                         if ((cnsPlane & 0xf0) != 0xa0 ||
182 (cnsPlane = cnspToIndex[cnsPlane&0x0f]) < 0)
183                             return CoderResult.malformedForLength(2);



And it definitely is better than the previous one, thanks! :-) Now maybe you might want to eye the
IBM db webrev, any change would benefit several charsets:-)

... I'm doing that since 2 hours. :-)

-Ulf


Reply via email to