diff options
author | Xin Hu <Xin.A.Hu@intel.com> | 2016-01-19 22:17:35 -0500 |
---|---|---|
committer | László Langó <llango.u-szeged@partner.samsung.com> | 2016-02-05 11:17:34 +0100 |
commit | 1466a5b3171d2f248880a3eaf93bb6326c211682 (patch) | |
tree | 82667833d0a70108e247062cace650b9e32ffc51 /jerry-core | |
parent | dfb22c34419d28c045c7954bab905067b04138f3 (diff) |
ecma_compare_ecma_strings_longpath performance improvement
- use switch to replace if
JerryScript-DCO-1.0-Signed-off-by: Xin Hu Xin.A.Hu@intel.com
Diffstat (limited to 'jerry-core')
-rw-r--r-- | jerry-core/ecma/base/ecma-helpers-string.cpp | 74 |
1 files changed, 30 insertions, 44 deletions
diff --git a/jerry-core/ecma/base/ecma-helpers-string.cpp b/jerry-core/ecma/base/ecma-helpers-string.cpp index 0d019e7d..56194a56 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.cpp +++ b/jerry-core/ecma/base/ecma-helpers-string.cpp @@ -1043,29 +1043,34 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri { if (string1_p->container == string2_p->container) { - if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE) - { - JERRY_ASSERT (string1_p->u.lit_cp.packed_value != string2_p->u.lit_cp.packed_value); - - return false; - } - else if (string1_p->container == ECMA_STRING_CONTAINER_MAGIC_STRING) - { - JERRY_ASSERT (string1_p->u.magic_string_id != string2_p->u.magic_string_id); - - return false; - } - else if (string1_p->container == ECMA_STRING_CONTAINER_MAGIC_STRING_EX) - { - JERRY_ASSERT (string1_p->u.magic_string_ex_id != string2_p->u.magic_string_ex_id); - - return false; - } - else if (string1_p->container == ECMA_STRING_CONTAINER_UINT32_IN_DESC) + switch ((ecma_string_container_t) string1_p->container) { - JERRY_ASSERT (string1_p->u.uint32_number != string2_p->u.uint32_number); - - return false; + case ECMA_STRING_CONTAINER_LIT_TABLE: + { + JERRY_ASSERT (string1_p->u.lit_cp.packed_value != string2_p->u.lit_cp.packed_value); + return false; + } + case ECMA_STRING_CONTAINER_MAGIC_STRING: + { + JERRY_ASSERT (string1_p->u.magic_string_id != string2_p->u.magic_string_id); + return false; + } + case ECMA_STRING_CONTAINER_MAGIC_STRING_EX: + { + JERRY_ASSERT (string1_p->u.magic_string_ex_id != string2_p->u.magic_string_ex_id); + return false; + } + case ECMA_STRING_CONTAINER_UINT32_IN_DESC: + { + JERRY_ASSERT (string1_p->u.uint32_number != string2_p->u.uint32_number); + return false; + } + default: + { + JERRY_ASSERT (string1_p->container == ECMA_STRING_CONTAINER_HEAP_NUMBER + || string1_p->container == ECMA_STRING_CONTAINER_HEAP_CHUNKS); + break; + } } } @@ -1111,29 +1116,10 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri return ecma_compare_chars_collection (chars_collection1_p, chars_collection2_p); } - case ECMA_STRING_CONTAINER_LIT_TABLE: - { - JERRY_ASSERT (string1_p->u.lit_cp.packed_value != string2_p->u.lit_cp.packed_value); - - return false; - } - case ECMA_STRING_CONTAINER_MAGIC_STRING: - { - JERRY_ASSERT (string1_p->u.magic_string_id != string2_p->u.magic_string_id); - - return false; - } - case ECMA_STRING_CONTAINER_MAGIC_STRING_EX: + default: { - JERRY_ASSERT (string1_p->u.magic_string_ex_id != string2_p->u.magic_string_ex_id); - - return false; - } - case ECMA_STRING_CONTAINER_UINT32_IN_DESC: - { - JERRY_ASSERT (string1_p->u.uint32_number != string2_p->u.uint32_number); - - return false; + JERRY_ASSERT (false); + break; } } } |