mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
Slight bignum-fixnum multiplication optimization
* libguile/integers.c (scm_integer_mul_zi): Use mpn_mul_1.
This commit is contained in:
parent
54bbe0b284
commit
62fc44e6ee
1 changed files with 8 additions and 4 deletions
|
@ -3094,13 +3094,17 @@ scm_integer_mul_zi (struct scm_bignum *x, scm_t_inum y)
|
|||
return SCM_INUM0;
|
||||
|
||||
struct scm_bignum *result = allocate_bignum (xn + 1);
|
||||
mp_limb_t *rd = bignum_limbs (result);
|
||||
const mp_limb_t *xd = bignum_limbs (x);
|
||||
mp_limb_t yd[1] = { long_magnitude (y) };
|
||||
mp_limb_t yd = long_magnitude (y);
|
||||
int negate = bignum_is_negative (x) != (y < 0);
|
||||
mpn_mul (bignum_limbs (result), xd, xn, yd, 1);
|
||||
mp_limb_t hi = mpn_mul_1 (rd, xd, xn, yd);
|
||||
if (hi)
|
||||
rd[xn] = hi;
|
||||
else
|
||||
result->u.z.size--;
|
||||
scm_remember_upto_here_1 (x);
|
||||
return normalize_bignum
|
||||
(bignum_negate_if (negate, (bignum_trim1 (result))));
|
||||
return normalize_bignum (bignum_negate_if (negate, (result)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue