[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 36/69: Simplify scm_bigprint
From: |
Andy Wingo |
Subject: |
[Guile-commits] 36/69: Simplify scm_bigprint |
Date: |
Fri, 7 Jan 2022 08:27:11 -0500 (EST) |
wingo pushed a commit to branch wip-inline-digits
in repository guile.
commit 24fad71be059c9aabbf94ebe89929b983e736265
Author: Andy Wingo <wingo@pobox.com>
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 ***/
- [Guile-commits] 40/69: positive?, negative? use integer lib, (continued)
- [Guile-commits] 40/69: positive?, negative? use integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 04/69: Implement abs with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 09/69: Implement ceiling-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 22/69: Implement scm_logand with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 29/69: Reimplement integer-expt in Scheme, Andy Wingo, 2022/01/07
- [Guile-commits] 27/69: Implement scm_lognot with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 26/69: Implement scm_logbit_p with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 25/69: Implement scm_logtest with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 33/69: Integer library takes bignums via opaque struct pointer, Andy Wingo, 2022/01/07
- [Guile-commits] 37/69: Build scm_integer_p on scm_is_integer, not vice versa, Andy Wingo, 2022/01/07
- [Guile-commits] 36/69: Simplify scm_bigprint,
Andy Wingo <=
- [Guile-commits] 38/69: Reimplement = on integer lib, clean up scm_num_eq_p, Andy Wingo, 2022/01/07
- [Guile-commits] 41/69: Simplify implementation of min, max, Andy Wingo, 2022/01/07
- [Guile-commits] 46/69: Clean up scm_divide, Andy Wingo, 2022/01/07
- [Guile-commits] 48/69: Fix scm_integer_to_double_z to always round; clean ups, Andy Wingo, 2022/01/07
- [Guile-commits] 54/69: Remove unused conv-{u,}integer.i.c, Andy Wingo, 2022/01/07
- [Guile-commits] 58/69: Expose frexp from integers lib, Andy Wingo, 2022/01/07
- [Guile-commits] 18/69: Implement round-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 28/69: Implement scm_modulo_expt with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 21/69: Implement lcm with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 30/69: Implement scm_ash with new integer library, Andy Wingo, 2022/01/07