On Oct 11, 2012, at 2:01 PM, Boris Zbarsky <bzbar...@mit.edu> wrote: > On 10/11/12 4:09 PM, Zack Weinberg wrote: >> I'm not seeing why the JS engine has to use any particular >> representation internally just because JS's exposed semantics are >> defined in terms of UCS-2. > > Well, because it's simpler and because it makes charAt() fast?
Simpler maybe, but since strings are immutable it's perfectly reasonable to have multiple internal string types and tag strings in the heap as being e.g. ASCII-only, so that they can be stored more compactly and still have fast accesses. It does mean more proliferation of string types, and string operations have to have multiple code paths, but I imagine for many applications it could have significant wins. I can't remember whether other engines do this. Dave _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo