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

feature, strlen are rarely called in jerry-core and jerry-ext, we can remove all the usage of strlen #4979

Open lygstate opened 2 years ago

lygstate commented 2 years ago

All the place calling to strlen are

Name    Line    Text    Path
jerry-debugger.c    150           size_t source_name_size = strlen ((const char *) source_name_p);  E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\api
jerryscript.c   5091                                    strlen (str_p));    E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\api
jerry-snapshot.c    1472        string_size = (lit_utf8_size_t) strlen (chars); E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\api
debugger.c  599         jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, string_p, strlen ((const char *) string_p));  E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\debugger
lit-strings.c   267   return (lit_utf8_size_t) strlen ((const char *) utf8_str_p);  E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\lit
module.c    187     if (module_p->name_p != NULL && strlen ((char *) module_p->name_p) == name_size E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-ext\module
print.c 153   jerry_size_t buffer_size = (jerry_size_t) (strlen (str_p));   E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-ext\util
sources.c   50      jerry_string ((const jerry_char_t *) path_p, (jerry_size_t) strlen (path_p), JERRY_ENCODING_UTF8);  E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-ext\util
sources.c   79      jerry_string ((const jerry_char_t *) path_p, (jerry_size_t) strlen (path_p), JERRY_ENCODING_UTF8);  E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-ext\util
main-snapshot.c 342     jerry_string ((const jerry_char_t *) file_name_p, (jerry_size_t) strlen (file_name_p), JERRY_ENCODING_UTF8);    E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-main
main-snapshot.c 348                                                 (jerry_size_t) strlen (function_args_p),    E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-main

We can improve the usage of strlen by improving the api of jerry-port and other related functions