Optimize string concatenation. (#2141)

This patch adds two new string concatenation functions:
ecma_append_chars_to_string and ecma_append_magic_string_to_string

The former appends a cesu8 byte array and the latter appends a magic string
to the end of an ecma-string. These two free (dereference) their ecma-string
argument, and this change is also applied to the original ecma_concat_ecma_strings
function which simplifies string handling in most cases.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-12-19 13:45:48 +01:00
committed by GitHub
parent bd574956e3
commit a2d3ea61eb
16 changed files with 369 additions and 555 deletions
@@ -82,8 +82,6 @@ ecma_builtin_function_helper_get_function_arguments (const ecma_value_t *argumen
return final_str;
}
ecma_string_t *comma_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_COMMA_CHAR);
for (ecma_length_t idx = 1; idx < arguments_list_len - 1; idx++)
{
ecma_value_t new_str = ecma_op_to_string (arguments_list_p[idx]);
@@ -98,18 +96,16 @@ ecma_builtin_function_helper_get_function_arguments (const ecma_value_t *argumen
}
ecma_string_t *final_str_p = ecma_get_string_from_value (final_str);
ecma_string_t *fragment_str_p = ecma_concat_ecma_strings (final_str_p, comma_str_p);
ecma_deref_ecma_string (final_str_p);
final_str_p = ecma_append_magic_string_to_string (final_str_p,
LIT_MAGIC_STRING_COMMA_CHAR);
ecma_string_t *new_str_p = ecma_get_string_from_value (new_str);
final_str_p = ecma_concat_ecma_strings (fragment_str_p, new_str_p);
final_str_p = ecma_concat_ecma_strings (final_str_p, new_str_p);
ecma_deref_ecma_string (new_str_p);
ecma_deref_ecma_string (fragment_str_p);
final_str = ecma_make_string_value (final_str_p);
}
ecma_deref_ecma_string (comma_str_p);
return final_str;
} /* ecma_builtin_function_helper_get_function_arguments */