From: Stephen Adams Date: Tue, 8 Jul 1997 01:22:28 +0000 (+0000) Subject: Changes in INT:->STRING to improve performance. 30% faster for huge X-Git-Tag: 20090517-FFI~5084 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=1df7e26e9f5a743d37d3d56673d725c67437568f;p=mit-scheme.git Changes in INT:->STRING to improve performance. 30% faster for huge bignums (10^1000), up to 2x-3x faster for small bignums (up to 10^100), slightly faster for fixnums. . Use a local version of DIGIT->CHAR since we don't need to check the radix. . PRINT-FIXNUM modified to be useful for generating digits in the middle of a number. . PRINT-MEDIUM and PRINT-LARGE work in units of several digits, the length of a unit pre-computed so that a unit can be printed using fixnum arithmetic. . PRINT-MEDIUM chops off groups of digits that can be printed by PRINT-FIXNUM. The microcode primitive LISTIFY-BIGNUM is no longer used. . PRINT-LARGE has a special check to try to avoid the last multiply in building the power stack (which is asymptotically 2/3 of the cost of building the stack). The recursion termination check is generalized to also catch sequences of digits with enough leading zeroes to be formatted by PRINT-FIXNUM (this can double the speed of printing numbers with many zeros). --- diff --git a/v7/src/runtime/arith.scm b/v7/src/runtime/arith.scm index 9c1ccb5a9..0c3ec67de 100644 --- a/v7/src/runtime/arith.scm +++ b/v7/src/runtime/arith.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: arith.scm,v 1.41 1997/07/07 20:24:45 adams Exp $ +$Id: arith.scm,v 1.42 1997/07/08 01:22:28 adams Exp $ Copyright (c) 1989-97 Massachusetts Institute of Technology @@ -344,7 +344,7 @@ MIT in each case. |# (set! *maximum-fixnum-radix-powers* (make-initialized-vector 37 (lambda (radix) - (and (fix:> radix 2) + (and (fix:>= radix 2) (let loop ((digits 0) (factor 1)) (let ((nf (int:* factor radix))) (if (fix:fixnum? nf)