Don't use strlen for string literals (#2517)
Their length (size) is known at compile time. Therefore `sizeof` is more efficient for them. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
+1
-3
@@ -251,7 +251,6 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint)
|
||||
[doctest]: # (test="link")
|
||||
|
||||
```c
|
||||
#include <string.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/debugger.h"
|
||||
|
||||
@@ -266,8 +265,7 @@ main (void)
|
||||
|
||||
// Protected execution of JavaScript code.
|
||||
const jerry_char_t script[] = "42";
|
||||
size_t script_size = strlen ((const char *) script);
|
||||
jerry_eval (script, script_size, JERRY_PARSE_NO_OPTS);
|
||||
jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
jerry_debugger_stop_at_breakpoint (false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user