I was working on optimizing a UUID scanner recently, and was baffled when I discovered that Java represents all char primitives in UTF-16, regardless of the original encoding.
So even given an ascii String, if you want to do something like
char c = input.charAt(index)
the JVM is going to jump to that index, check whether the character at that index isLatin(), then cast that single byte into to a 2 byte char...
every single time.
in the naive solution, omething like 15% of the CPU cycles were spent checking isLatin() over and over again
So even given an ascii String, if you want to do something like
char c = input.charAt(index)
the JVM is going to jump to that index, check whether the character at that index isLatin(), then cast that single byte into to a 2 byte char... every single time.
in the naive solution, omething like 15% of the CPU cycles were spent checking isLatin() over and over again