Skip to content

Optimising the ToString operation #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2016

Conversation

robertsipka
Copy link
Contributor

Create new ecma-string from positive integers without cast it to ecma_number

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]

@LaszloLango LaszloLango added enhancement An improvement performance Affects performance labels May 25, 2016
res_p = ecma_new_ecma_string_from_uint32 ((uint32_t) (ecma_get_integer_from_value (value)));
}
}
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.

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.

@@ -352,10 +352,23 @@ ecma_op_to_string (ecma_value_t value) /**< ecma value */

if (ecma_is_value_string (value))
{
res_p = ecma_get_string_from_value (value);
res_p = ecma_get_string_from_value (value);ecma-array-object.c
Copy link
Contributor

Choose a reason for hiding this comment

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

accident change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly, fixed.

@LaszloLango
Copy link
Contributor

LGTM

1 similar comment
@zherczeg
Copy link
Member

LGTM

Create new ecma-string from positive integers without cast it to ecma_number

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
@robertsipka
Copy link
Contributor Author

rebased with master

@LaszloLango LaszloLango merged commit 3796987 into jerryscript-project:master May 26, 2016
@robertsipka robertsipka deleted the number_opt branch November 24, 2016 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement performance Affects performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants