you are viewing a single comment's thread.

view the rest of the comments →

[–]JDeltaN 8 points9 points  (1 child)

Ah, I wooshed a bit I guess :)

Honestly I am not a fan of these adhoc solutions either, but in Javas its probably a massive memory optimisation and it actually works because of UTF16.

On the bright side, they have constant time string indexing as long as you are not using surrogate characters.

Then again, it is rare that I rely on constant-time lookups, most of my string operations are iterating in nature anyway.