[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 35/85: Simplify scm_bigprint
From: |
Andy Wingo |
Subject: |
[Guile-commits] 35/85: Simplify scm_bigprint |
Date: |
Thu, 13 Jan 2022 03:40:19 -0500 (EST) |
wingo pushed a commit to branch main
in repository guile.
commit 24ce3cedfc286c3cc793d41ed557df8c449363e9
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] 21/85: Implement scm_logand with new integer library, (continued)
- [Guile-commits] 21/85: Implement scm_logand with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 16/85: Implement round-quotient with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 25/85: Implement scm_logbit_p with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 14/85: Implement centered-remainder with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 10/85: Implement truncate-quotient with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 26/85: Implement scm_lognot with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 12/85: Implement truncate-divide with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 29/85: Implement scm_ash with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 31/85: Implement scm_logcount with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 33/85: Implement scm_integer_length with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 35/85: Simplify scm_bigprint,
Andy Wingo <=
- [Guile-commits] 34/85: Implement integer-to-string with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 36/85: Build scm_integer_p on scm_is_integer, not vice versa, Andy Wingo, 2022/01/13
- [Guile-commits] 37/85: Reimplement = on integer lib, clean up scm_num_eq_p, Andy Wingo, 2022/01/13
- [Guile-commits] 40/85: Simplify implementation of min, max, Andy Wingo, 2022/01/13
- [Guile-commits] 42/85: Simplify scm_difference, use integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 47/85: Fix scm_integer_to_double_z to always round; clean ups, Andy Wingo, 2022/01/13
- [Guile-commits] 50/85: Reimplement scm_{to,from}_{int32,uint32}, Andy Wingo, 2022/01/13
- [Guile-commits] 67/85: scm_to_ipv6 uses scm_to_mpz, Andy Wingo, 2022/01/13
- [Guile-commits] 68/85: Bignums avoid both custom GMP allocator and finalizers, Andy Wingo, 2022/01/13
- [Guile-commits] 69/85: take_mpz optimization, Andy Wingo, 2022/01/13