Rewrite of IBM doublebyte charsets (original) (raw)

Ulf Zibis Ulf.Zibis at gmx.de
Sun May 17 20:11:53 UTC 2009


Am 15.05.2009 01:48, Xueming Shen schrieb:

Ulf Zibis wrote:

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. With the motivation of pushing you move on to the ibm charsets as quick as possible:-) I've tried both xor and the byte[256]. since we have to do "int cnsPlane = (sa[sp +1] ^ 0xa0) && 0xff;", (without & 0xff, you got a negative sign extension),

Oops, it should be "int cnsPlane = (sa[sp +1] ^ (byte)0xa0);"

it is not faster than the existing one, actually my "not that accurate" benchmark shows it is slower...

Maybe XOR is not covered by Bug ID 6797305 ... Christian Thalinger?

-Ulf



More information about the core-libs-dev mailing list