Remove duplicate is_object check when calling ecma_op_to_primtive (#3899)

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-06-30 13:18:40 +02:00
committed by GitHub
parent 034b3b63f5
commit c0b594fa69
2 changed files with 104 additions and 89 deletions
+26 -27
View File
@@ -16,6 +16,7 @@
#include "ecma-comparison.h"
#include "ecma-conversion.h"
#include "ecma-globals.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
@@ -150,33 +151,6 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
return ecma_op_abstract_equality_compare (x, ecma_make_integer_value (ecma_is_value_true (y) ? 1 : 0));
}
if (ecma_is_value_object (x))
{
if (ecma_is_value_string (y)
#if ENABLED (JERRY_ESNEXT)
|| ecma_is_value_symbol (y)
#endif /* ENABLED (JERRY_ESNEXT) */
|| ecma_is_value_number (y))
{
/* 9. */
ecma_value_t x_prim_value = ecma_op_to_primitive (x, ECMA_PREFERRED_TYPE_NO);
if (ECMA_IS_VALUE_ERROR (x_prim_value))
{
return x_prim_value;
}
ecma_value_t compare_result = ecma_op_abstract_equality_compare (x_prim_value, y);
ecma_free_value (x_prim_value);
return compare_result;
}
/* 1., f. */
/* Note: the (x == y) comparison captures the true case. */
return ECMA_VALUE_FALSE;
}
if (ecma_is_value_boolean (x))
{
/* 6. */
@@ -193,6 +167,31 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
return ecma_make_boolean_value (is_equal);
}
JERRY_ASSERT (ecma_is_value_object (x));
if (ecma_is_value_string (y)
#if ENABLED (JERRY_ESNEXT)
|| ecma_is_value_symbol (y)
#endif /* ENABLED (JERRY_ESNEXT) */
|| ecma_is_value_number (y))
{
/* 9. */
ecma_object_t *obj_p = ecma_get_object_from_value (x);
ecma_value_t def_value = ecma_op_object_default_value (obj_p, ECMA_PREFERRED_TYPE_NO);
if (ECMA_IS_VALUE_ERROR (def_value))
{
return def_value;
}
ecma_value_t compare_result = ecma_op_abstract_equality_compare (def_value, y);
ecma_free_value (def_value);
return compare_result;
}
return ECMA_VALUE_FALSE;
} /* ecma_op_abstract_equality_compare */