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:
Akos Kiss
2018-09-17 10:07:24 +02:00
committed by László Langó
parent 2d83d8ed17
commit 3d3a8008a8
24 changed files with 367 additions and 389 deletions
+7 -7
View File
@@ -23,17 +23,17 @@ int main (void)
{
return 0;
}
const char *test_source = (
"var a = 'hello';"
"var b = 'world';"
"var c = a + ' ' + b;"
);
const jerry_char_t test_source[] = TEST_STRING_LITERAL (
"var a = 'hello';"
"var b = 'world';"
"var c = a + ' ' + b;"
);
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t parsed_code_val = jerry_parse (NULL,
0,
(jerry_char_t *) test_source,
strlen (test_source),
test_source,
sizeof (test_source) - 1,
JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));