Skip to content

Commit

Permalink
If dividing by 1, just return the numerator
Browse files Browse the repository at this point in the history
This avoids allocating a new mp_int and actually performing the
division.
  • Loading branch information
MasterDuke17 committed Oct 27, 2017
1 parent 213fc77 commit d42bf0c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/math/bigintops.c
Expand Up @@ -554,6 +554,10 @@ MVMObject *MVM_bigint_div(MVMThreadContext *tc, MVMObject *result_type, MVMObjec

int mp_result;

if (!MVM_BIGINT_IS_BIG(bb) && bb->u.smallint.value == 1) {
return a;
}

MVMROOT(tc, a, {
MVMROOT(tc, b, {
result = MVM_repr_alloc_init(tc, result_type);
Expand Down

0 comments on commit d42bf0c

Please sign in to comment.