From 6430d1a3a31e012dbaf17c124f2a2330bbca52d7 Mon Sep 17 00:00:00 2001 From: Szilagyi Adam Date: Mon, 24 Feb 2020 11:34:07 +0100 Subject: [PATCH] Use stringbuilder in static_snapshot_error_unsupported_literal (#3574) JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu --- jerry-core/api/jerry-snapshot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index ae9f3eacc..89b812d5b 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -295,20 +295,21 @@ static void static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< snapshot globals */ ecma_value_t literal) /**< literal form the literal pool */ { - const lit_utf8_byte_t error_prefix[] = "Unsupported static snapshot literal: "; + ecma_stringbuilder_t builder = ecma_stringbuilder_create (); - ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 (error_prefix, sizeof (error_prefix) - 1); + ecma_stringbuilder_append_raw (&builder, (lit_utf8_byte_t *) "Unsupported static snapshot literal: ", 37); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (literal)); ecma_string_t *literal_string_p = ecma_op_to_string (literal); JERRY_ASSERT (literal_string_p != NULL); - error_message_p = ecma_concat_ecma_strings (error_message_p, literal_string_p); + ecma_stringbuilder_append (&builder, literal_string_p); + ecma_deref_ecma_string (literal_string_p); - ecma_object_t *error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE, error_message_p); - ecma_deref_ecma_string (error_message_p); + ecma_object_t *error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE, + ecma_stringbuilder_finalize (&builder)); globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p); } /* static_snapshot_error_unsupported_literal */