From 4c71a77f2c39a8158c80b40af1a5cc2358251a00 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 25 Jan 2019 06:33:29 -0800 Subject: Provide faster bignum-in-fixed-integer range tests in MPI. * mpi/mpi.c (mp_in_range, mp_in_intptr_range, mp_in_uintptr_range): New functions. * mpi/mpi.h (mp_in_range, mp_in_intptr_range, mp_in_uintptr_range): Declared. * arith.c (NUM_MAX_MP, INT_PTR_MAX_MP, UINT_PTR_MAX_MP, INT_PTR_MAX_SUCC_MP): Static variables removed. Note that INT_PTR_MAX_MP was not used at all! (normalize): Use mp_in_range instead magnitude comparison to NUM_MAX_MP. (in_int_ptr_range, in_uint_ptr_range): Static functions removed. (c_unum): Use mp_in_uintptr_range instead of in_uint_ptr_range. (arith_init): Remove initializations of removed variables. (arith_free_all): Remove cleanup of removed variables, leaving function empty. * lib.c (c_num): Use mp_in_intptr_range instead of in_int_ptr_range. --- lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 26806b41..7e4edd9c 100644 --- a/lib.c +++ b/lib.c @@ -3105,7 +3105,7 @@ cnum c_num(val n) case CHR: case NUM: return coerce(cnum, n) >> TAG_SHIFT; case BGNUM: - if (in_int_ptr_range(n)) { + if (mp_in_intptr_range(mp(n))) { int_ptr_t out; mp_get_intptr(mp(n), &out); return out; -- cgit v1.2.3