-
Notifications
You must be signed in to change notification settings - Fork 7.9k
More BCMath performance improvements #14106
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
Conversation
The strings are always new, not interned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made one comment, but LGTM
@@ -179,9 +177,9 @@ PHP_FUNCTION(bcadd) | |||
goto cleanup; | |||
} | |||
|
|||
bc_add (first, second, &result, scale); | |||
result = bc_add (first, second, scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result = bc_add (first, second, scale); | |
bc_num result = bc_add (first, second, scale); |
Maybe can declare and initialize it at the same time and remove the result from the cleanup.
But I'm not sure if it affects performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I expect this will only make the failure path potentially faster, as it can avoid a call then to the freeing. For the success path I don't think it matters, but I guess feel free to try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes make sense to me.
Please rebase to keep commit history
Builds upon all previous PRs.
With benchmark from #14076.
Before:
After:
One of the changes here is avoiding initializing and releasing temporary numbers, but only done for the most simple (and common) functions.