Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion jerry-core/ecma/operations/ecma-conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,20 @@ ecma_op_to_string (ecma_value_t value) /**< ecma value */
res_p = ecma_get_string_from_value (value);
res_p = ecma_copy_or_ref_ecma_string (res_p);
}
else if (ecma_is_value_number (value))
else if (ecma_is_value_integer_number (value))
{
ecma_integer_value_t num = ecma_get_integer_from_value (value);

if (num < 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a newline before this. After that LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks.

{
res_p = ecma_new_ecma_string_from_number ((ecma_number_t) num);
}
else
{
res_p = ecma_new_ecma_string_from_uint32 ((uint32_t) num);
}
}
else if (ecma_is_value_float_number (value))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call ecma_get_integer_from_value (value) first, then check the sign, and that makes ecma_get_number_from_value call unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed, thanks! I've updated this patch.

{
ecma_number_t num = ecma_get_number_from_value (value);
res_p = ecma_new_ecma_string_from_number (num);
Expand Down