Commit 9684296a authored by Philipp Stephani's avatar Philipp Stephani

Refactoring: Factor out a function to set an mpz_t from a Lisp int.

* src/bignum.h (mpz_set_integer): New function.

* src/emacs-module.c (module_make_big_integer): Use it.
parent 1242a636
Pipeline #1560 failed with stage
in 57 minutes and 52 seconds
......@@ -94,6 +94,18 @@ bignum_integer (mpz_t *tmp, Lisp_Object i)
return &XBIGNUM (i)->value;
}
/* Set RESULT to the value stored in the Lisp integer I. If I is a
big integer, copy it to RESULT. RESULT must already be
initialized. */
INLINE void
mpz_set_integer (mpz_t result, Lisp_Object i)
{
if (FIXNUMP (i))
mpz_set_intmax (result, XFIXNUM (i));
else
mpz_set (result, XBIGNUM (i)->value);
}
INLINE_HEADER_END
#endif /* BIGNUM_H */
......@@ -785,10 +785,7 @@ module_extract_big_integer (emacs_env *env, emacs_value value,
MODULE_FUNCTION_BEGIN ();
Lisp_Object o = value_to_lisp (value);
CHECK_INTEGER (o);
if (FIXNUMP (o))
mpz_set_intmax (result->value, XFIXNUM (o));
else
mpz_set (result->value, XBIGNUM (o)->value);
mpz_set_integer (result->value, o);
}
static emacs_value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment