wingo pushed a commit to branch wip-inline-digits
in repository guile.

commit 24fad71be059c9aabbf94ebe89929b983e736265
Author: Andy Wingo <[email protected]>
AuthorDate: Tue Jan 4 11:20:22 2022 +0100

    Simplify scm_bigprint
    
    * libguile/numbers.c (scm_bigprint): Just convert the number to a string
    and write that.  Adds a copy but if we optimize scm_integer_to_string_z
    then that will be fixed.
---
 libguile/numbers.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 1b6d29efa..51e5ee19a 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -3820,13 +3820,8 @@ scm_i_print_fraction (SCM sexp, SCM port, 
scm_print_state *pstate SCM_UNUSED)
 int
 scm_bigprint (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
 {
-  char *str = mpz_get_str (NULL, 10, SCM_I_BIG_MPZ (exp));
-  size_t len = strlen (str);
-  void (*freefunc) (void *, size_t);
-  mp_get_memory_functions (NULL, NULL, &freefunc);
-  scm_remember_upto_here_1 (exp);
-  scm_lfwrite (str, len, port);
-  freefunc (str, len + 1);
+  SCM str = scm_integer_to_string_z (scm_bignum (exp), 10);
+  scm_c_put_string (port, str, 0, scm_c_string_length (str));
   return !0;
 }
 /*** END nums->strs ***/

Reply via email to