[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9684296: Refactoring: Factor out a function to set
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 9684296: Refactoring: Factor out a function to set an mpz_t from a Lisp int. |
Date: |
Sat, 4 May 2019 17:32:46 -0400 (EDT) |
branch: master
commit 9684296a5d3405885e44d0b422deef19329567ef
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
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.
---
src/bignum.h | 12 ++++++++++++
src/emacs-module.c | 5 +----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/bignum.h b/src/bignum.h
index 4c670bd..743a18f 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -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 */
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 6b56146..1a7a21a 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9684296: Refactoring: Factor out a function to set an mpz_t from a Lisp int.,
Philipp Stephani <=