jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.91k stars 669 forks source link

lit_get_magic_string_utf8 can be improved without the need of strlen #4978

Open lygstate opened 2 years ago

lygstate commented 2 years ago

According to https://github.com/jerryscript-project/jerryscript/blob/badfdf4dba1fa0a15bd78163c1713ada5e65cd22/jerry-core/lit/lit-magic-strings.c#L44

We can use lit_magic_strings[id] - lit_magic_strings[id+1] to calcuate the length of lit_magic_strings[id], without the need of strlen.