From fb6bdd151aa9e8cfff61a475614df7dc6570f4a9 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Tue, 18 Nov 2014 17:28:03 +0300 Subject: [PATCH] Moving part of ecma_compare_ecma_strings to ecma_compare_ecma_strings_longpath. --- src/libecmaobjects/ecma-helpers-string.c | 108 +++++++++++------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/libecmaobjects/ecma-helpers-string.c b/src/libecmaobjects/ecma-helpers-string.c index ff7bc467a..021e2db1d 100644 --- a/src/libecmaobjects/ecma-helpers-string.c +++ b/src/libecmaobjects/ecma-helpers-string.c @@ -795,6 +795,55 @@ static bool __noinline ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-string */ const ecma_string_t *string2_p) /* ecma-string */ { + if (likely (ecma_string_get_length (string1_p) != ecma_string_get_length (string2_p))) + { + return false; + } + + if (string1_p->container == string2_p->container) + { + switch ((ecma_string_container_t) string1_p->container) + { + case ECMA_STRING_CONTAINER_HEAP_NUMBER: + { + ecma_number_t *num1_p, *num2_p; + num1_p = ECMA_GET_NON_NULL_POINTER (string1_p->u.number_cp); + num2_p = ECMA_GET_NON_NULL_POINTER (string2_p->u.number_cp); + + if (ecma_number_is_nan (*num1_p) + && ecma_number_is_nan (*num2_p)) + { + return true; + } + + return (*num1_p == *num2_p); + } + case ECMA_STRING_CONTAINER_CHARS_IN_DESC: + { + JERRY_ASSERT (ecma_string_get_length (string1_p) == ecma_string_get_length (string2_p)); + + return (__memcmp (string1_p->u.chars, + string2_p->u.chars, + (size_t) (ecma_string_get_length (string1_p) * ((ssize_t) sizeof (ecma_char_t)))) == 0); + } + case ECMA_STRING_CONTAINER_HEAP_CHUNKS: + { + return ecma_compare_strings_in_heap_chunks (string1_p, string2_p); + } + case ECMA_STRING_CONTAINER_CONCATENATION: + { + /* long path */ + break; + } + case ECMA_STRING_CONTAINER_LIT_TABLE: + case ECMA_STRING_CONTAINER_MAGIC_STRING: + case ECMA_STRING_CONTAINER_UINT32_IN_DESC: + { + JERRY_UNREACHABLE (); + } + } + } + if (string1_p->container == ECMA_STRING_CONTAINER_HEAP_CHUNKS) { const ecma_string_t *tmp_string_p = string1_p; @@ -919,6 +968,11 @@ ecma_compare_ecma_strings (const ecma_string_t *string1_p, /* ecma-string */ { JERRY_ASSERT (string1_p != NULL && string2_p != NULL); + if (unlikely (string1_p == string2_p)) + { + return true; + } + if (string1_p->container == string2_p->container) { if (likely (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)) @@ -935,60 +989,6 @@ ecma_compare_ecma_strings (const ecma_string_t *string1_p, /* ecma-string */ } } - if (unlikely (string1_p == string2_p)) - { - return true; - } - - if (likely (ecma_string_get_length (string1_p) != ecma_string_get_length (string2_p))) - { - return false; - } - - if (string1_p->container == string2_p->container) - { - switch ((ecma_string_container_t) string1_p->container) - { - case ECMA_STRING_CONTAINER_HEAP_NUMBER: - { - ecma_number_t *num1_p, *num2_p; - num1_p = ECMA_GET_NON_NULL_POINTER (string1_p->u.number_cp); - num2_p = ECMA_GET_NON_NULL_POINTER (string2_p->u.number_cp); - - if (ecma_number_is_nan (*num1_p) - && ecma_number_is_nan (*num2_p)) - { - return true; - } - - return (*num1_p == *num2_p); - } - case ECMA_STRING_CONTAINER_CHARS_IN_DESC: - { - JERRY_ASSERT (ecma_string_get_length (string1_p) == ecma_string_get_length (string2_p)); - - return (__memcmp (string1_p->u.chars, - string2_p->u.chars, - (size_t) (ecma_string_get_length (string1_p) * ((ssize_t) sizeof (ecma_char_t)))) == 0); - } - case ECMA_STRING_CONTAINER_HEAP_CHUNKS: - { - return ecma_compare_strings_in_heap_chunks (string1_p, string2_p); - } - case ECMA_STRING_CONTAINER_CONCATENATION: - { - /* long path */ - break; - } - case ECMA_STRING_CONTAINER_LIT_TABLE: - case ECMA_STRING_CONTAINER_MAGIC_STRING: - case ECMA_STRING_CONTAINER_UINT32_IN_DESC: - { - JERRY_UNREACHABLE (); - } - } - } - return ecma_compare_ecma_strings_longpath (string1_p, string2_p); } /* ecma_compare_ecma_strings */