4 ms·
Read the sentence before that: > This also makes it possible to store only a single copy of short strings, to improve memory efficiency, cache locality, and so
by rntz 16y ago
Read the sentence before that:
> This also makes it possible to store only a single copy of short strings, to improve memory efficiency, cache locality, and so on.
He's specifically talking about interning strings. He even links to the wikipedia article on string interning. I recall reading that Lua interns strings by default, and a quick google search seems to confirm my belief. However, with only one example, you're right: interning /all/ strings is unusual. Interning all "short" strings, his suggestion, is a more feasible heuristic, and then (if finding the length of a string is O(1)) comparing two short strings amounts to little more than a pointer comparison. I don't know whether there are any languages that do that.