Skip to content
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

Optimize the check for negative bignums. #405

Closed
wants to merge 2 commits into from
Closed

Optimize the check for negative bignums. #405

wants to merge 2 commits into from

Conversation

LemonBoy
Copy link
Contributor

@LemonBoy LemonBoy commented Sep 9, 2016

We save a function call for every check.

@@ -543,13 +543,13 @@ MVMObject *MVM_bigint_div(MVMThreadContext *tc, MVMObject *result_type, MVMObjec
bc = get_bigint_body(tc, result);

if (MVM_BIGINT_IS_BIG(ba)) {
cmp_a = mp_cmp_d(ba->u.bigint, 0);
cmp_a = SIGN(ba->u.bigint) == MP_NEG ? MP_LT : MP_GT;
} else {
// we only care about MP_LT or !MP_LT, so we give MP_GT even for 0.
cmp_a = ba->u.smallint.value < 0 ? MP_LT : MP_GT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could probably make this code use MP_NEG and MP_ZPOS instead

We save a function call for every check.
Two mp_neg calls have no effect and mp_get_int64 doesn't care about the
sign.
@LemonBoy LemonBoy closed this Sep 27, 2016
@jnthn
Copy link
Member

jnthn commented Oct 1, 2016

@LemonBoy any reason to close this besides "too slow to get review"? Finally got around to looking at it now, and it looks fine.

@LemonBoy
Copy link
Contributor Author

LemonBoy commented Oct 1, 2016

None in particular, it got killed in a housekeeping spree :)
You can easily grab the patch and apply it using git though, I'd be happy to see this applied.

@MasterDuke17
Copy link
Contributor

I seem to recall this was related to https://rt.perl.org/Ticket/Display.html?id=128035, was the patch actually applied?

@jnthn
Copy link
Member

jnthn commented Dec 7, 2016

D'oh, I forgot. It's applied now, though it was a welcome optimization rather than a behavior change, so no impact on the RT in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants