Small refactorings
Modifications: * eliminate unnecessary variables, functions * use ECMA_NUMBER macros where it is possible * simplify code * minor style fix (comments, increase-decrease operators) JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
@@ -961,18 +961,18 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t j, /**< le
|
||||
{
|
||||
if (k_is_undef)
|
||||
{
|
||||
*result_p = ecma_int32_to_number (0);
|
||||
*result_p = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
*result_p = ecma_int32_to_number (1);
|
||||
*result_p = ECMA_NUMBER_ONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k_is_undef)
|
||||
{
|
||||
*result_p = ecma_int32_to_number (-1);
|
||||
*result_p = ECMA_NUMBER_MINUS_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -986,15 +986,15 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t j, /**< le
|
||||
|
||||
if (ecma_compare_ecma_strings_relational (j_str_p, k_str_p))
|
||||
{
|
||||
*result_p = ecma_int32_to_number (-1);
|
||||
*result_p = ECMA_NUMBER_MINUS_ONE;
|
||||
}
|
||||
else if (!ecma_compare_ecma_strings (j_str_p, k_str_p))
|
||||
{
|
||||
*result_p = ecma_int32_to_number (1);
|
||||
*result_p = ECMA_NUMBER_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*result_p = ecma_int32_to_number (0);
|
||||
*result_p = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (k_value);
|
||||
@@ -1766,7 +1766,7 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
|
||||
if (len == 0)
|
||||
{
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ecma_int32_to_number (-1);
|
||||
*num_p = ECMA_NUMBER_MINUS_ONE;
|
||||
ret_value = ecma_make_number_value (num_p);
|
||||
}
|
||||
else
|
||||
@@ -1774,7 +1774,7 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
|
||||
/* 5. */
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_from_idx, arg2, ret_value);
|
||||
|
||||
ecma_number_t found_index = ecma_int32_to_number (-1);
|
||||
ecma_number_t found_index = ECMA_NUMBER_MINUS_ONE;
|
||||
|
||||
uint32_t from_idx = ecma_builtin_helper_array_index_normalize (arg_from_idx, len);
|
||||
|
||||
@@ -1863,7 +1863,7 @@ ecma_builtin_array_prototype_object_last_index_of (ecma_value_t this_arg, /**< t
|
||||
uint32_t len = ecma_number_to_uint32 (len_number);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ecma_int32_to_number (-1);
|
||||
*num_p = ECMA_NUMBER_MINUS_ONE;
|
||||
|
||||
/* 4. */
|
||||
if (len == 0)
|
||||
|
||||
@@ -523,7 +523,7 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**
|
||||
ecma_string_t *search_str_p = ecma_get_string_from_value (search_str_val);
|
||||
|
||||
ecma_number_t *ret_num_p = ecma_alloc_number ();
|
||||
*ret_num_p = ecma_int32_to_number (-1);
|
||||
*ret_num_p = ECMA_NUMBER_MINUS_ONE;
|
||||
|
||||
/* 8 (indexOf) -- 9 (lastIndexOf) */
|
||||
ecma_length_t index_of = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015-2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -572,16 +572,16 @@ ecma_builtin_math_object_round (ecma_value_t this_arg __attr_unused___, /**< 'th
|
||||
*num_p = arg_num;
|
||||
}
|
||||
else if (ecma_number_is_negative (arg_num)
|
||||
&& arg_num >= -0.5f)
|
||||
&& arg_num >= -ECMA_NUMBER_HALF)
|
||||
{
|
||||
*num_p = ecma_number_negate (0.0f);
|
||||
*num_p = ecma_number_negate (ECMA_NUMBER_ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ecma_number_t up_half = arg_num + 0.5f;
|
||||
const ecma_number_t down_half = arg_num - 0.5f;
|
||||
const ecma_number_t up_rounded = up_half - ecma_op_number_remainder (up_half, 1);
|
||||
const ecma_number_t down_rounded = down_half - ecma_op_number_remainder (down_half, 1);
|
||||
const ecma_number_t up_half = arg_num + ECMA_NUMBER_HALF;
|
||||
const ecma_number_t down_half = arg_num - ECMA_NUMBER_HALF;
|
||||
const ecma_number_t up_rounded = up_half - ecma_op_number_remainder (up_half, ECMA_NUMBER_ONE);
|
||||
const ecma_number_t down_rounded = down_half - ecma_op_number_remainder (down_half, ECMA_NUMBER_ONE);
|
||||
|
||||
if (up_rounded - arg_num <= arg_num - down_rounded)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015-2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -367,15 +367,15 @@ ecma_builtin_string_prototype_object_locale_compare (ecma_value_t this_arg, /**<
|
||||
|
||||
if (ecma_compare_ecma_strings_relational (this_string_p, arg_string_p))
|
||||
{
|
||||
*result_p = ecma_int32_to_number (-1);
|
||||
*result_p = ECMA_NUMBER_MINUS_ONE;
|
||||
}
|
||||
else if (!ecma_compare_ecma_strings (this_string_p, arg_string_p))
|
||||
{
|
||||
*result_p = ecma_int32_to_number (1);
|
||||
*result_p = ECMA_NUMBER_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*result_p = ecma_int32_to_number (0);
|
||||
*result_p = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
ret_value = ecma_make_number_value (result_p);
|
||||
|
||||
Reference in New Issue
Block a user