From: John Benediktsson Date: Tue, 13 Feb 2024 23:55:32 +0000 (-0800) Subject: math.parser: use append! and suffix! X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=a4f0a5a67ab3bf8f7904f948245922d1b67e4448 math.parser: use append! and suffix! --- diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index 344864da99..c5e7c2e115 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -968,18 +968,18 @@ CONSTANT: lookup-table { [ mantissa-expt-normalize* ] [ shorter-interval? ] 2bi [ shorter-interval ] [ normal-interval ] if ; inline -: ?minus ( accum ? -- accum ) [ CHAR: - over push ] when ; inline +: ?minus ( accum ? -- accum ) [ CHAR: - suffix! ] when ; inline : ?exponent ( accum e -- accum ) - CHAR: e pick push - dup 0 >= [ CHAR: + pick push ] when - >dec over push-all ; inline + [ CHAR: e suffix! ] dip + [ 0 >= [ CHAR: + suffix! ] when ] + [ >dec append! ] bi ; inline : exponential-format ( neg? f-str f-len e -- sbuf ) + 1 - [ 24 ] 3dip [ ?minus ] [ unclip-slice pick push [ - CHAR: . pick push over push-all + CHAR: . pick push append! ] unless-empty ] [ ?exponent ] tri* ; inline @@ -988,12 +988,13 @@ CONSTANT: lookup-table { { [ dup 0 >= ] [ nip 0 swap 1 ] } { [ 2dup neg <= ] [ over + neg 1 swap ] } [ nip neg 0 0 ] - } cond [ cut-slice* ] 2dip rot - [ ?minus ] 4dip - [ over push-all ] 3dip - [ CHAR: 0 over push-all CHAR: . over push ] - [ CHAR: 0 over push-all ] - [ over push-all ] tri* ; inline + } cond [ cut-slice* ] 2dip rot { + [ ?minus ] + [ append! ] + [ CHAR: 0 append! CHAR: . suffix! ] + [ CHAR: 0 append! ] + [ append! ] + } spread ; inline : (format) ( neg? f e quot -- str ) [ >dec dup length ] 2dip call "" like ; inline