Skip to content

Commit

Permalink
save an allocation in nqp_bigint_div
Browse files Browse the repository at this point in the history
the mp_div code allows NULL as remainder, so no need to allocate it
  • Loading branch information
moritz committed Nov 15, 2011
1 parent 0e7280c commit f1b02e1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/ops/nqp_bigint.ops
Expand Up @@ -159,13 +159,10 @@ inline op nqp_bigint_mul(out PMC, in PMC, in PMC) :base_core {
inline op nqp_bigint_div(out PMC, in PMC, in PMC) :base_core {
mp_int *a = get_bigint(interp, $2);
mp_int *b = get_bigint(interp, $3);
mp_int remainder;
int result;
mp_init(&remainder);
$1 = REPR($2)->allocate(interp, STABLE($2));
REPR($1)->initialize(interp, STABLE($1), OBJECT_BODY($1));
result = mp_div(a, b, get_bigint(interp, $1), &remainder);
mp_clear(&remainder);
result = mp_div(a, b, get_bigint(interp, $1), NULL);
if (result == MP_VAL)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Divide by zero");
Expand Down

0 comments on commit f1b02e1

Please sign in to comment.