mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-17 23:02:31 -08:00
Simplified _ecl_get_fixnum/index under the assumption that input arguments will never include the zero fixnum.
This commit is contained in:
parent
17d0dc9b56
commit
fa38d10ee4
1 changed files with 8 additions and 12 deletions
20
src/c/big.d
20
src/c/big.d
|
|
@ -364,28 +364,24 @@ _ecl_big_set_index(cl_object x, cl_index f)
|
|||
cl_fixnum
|
||||
_ecl_big_get_fixnum(cl_object x)
|
||||
{
|
||||
if (x->big.big_size == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
cl_fixnum n = x->big.big_limbs[0];
|
||||
return (x->big.big_size > 0) ? n : -n;
|
||||
}
|
||||
/* INV: x is a bignum and thus size != 0 */
|
||||
cl_fixnum output = x->big.big_limbs[0];
|
||||
return (x->big.big_size > 0) ? output : -output;
|
||||
}
|
||||
|
||||
cl_index
|
||||
_ecl_big_get_index(cl_object x)
|
||||
{
|
||||
if (x->big.big_size == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return (cl_index)x->big.big_limbs[0];
|
||||
}
|
||||
/* INV: x is a bignum and thus size != 0 */
|
||||
cl_index output = x->big.big_limbs[0];
|
||||
return (x->big.big_size > 0)? output : ~(output - 1);
|
||||
}
|
||||
|
||||
bool
|
||||
_ecl_big_fits_in_index(cl_object x)
|
||||
{
|
||||
return (x->big.big_size & (~1)) == 0;
|
||||
/* INV: x is a bignum and thus size != 0 */
|
||||
return (x->big.big_size ^ 1) == 0;
|
||||
}
|
||||
#else
|
||||
# error "ECL cannot build with GMP when both long and mp_limb_t are smaller than cl_fixnum"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue