lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, 17 Jun 2019 at 12:57, 云风 Cloud Wu <cloudwu@gmail.com> wrote:
>
> Lua has unique string type before 5.2.1 , all the strings is interning
> for fast comparison .
>
> Lua 5.2.1 add a new internal long string type because of hash DoS
> attack , but short string is still interning. I guess the reason is
> the performance of string comparison is very important to lua , string
> interning can reduce the string comparison from O(n) to O(1).

There is also a benefit in reduced RAM usage (in some applications).
But importantly a string's hash is also used for table lookups, which
is quite a key part of Lua.

Regards,
Matthew