]> gitweb.factorcode.org Git - factor.git/commitdiff
units.reduction: avoid double length calls in find-unit-suffix.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 14 Jul 2015 22:58:23 +0000 (15:58 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 14 Jul 2015 22:58:23 +0000 (15:58 -0700)
extra/units/reduction/reduction.factor

index db7d774b4f085c7abb95ff9f22132b596bc7a512..3a75d359fc22188a69220884d090df122c63abd3 100644 (file)
@@ -16,9 +16,9 @@ CONSTANT: unit-suffix-hash H{
     [ * ] dip swap ^ ; inline
 
 :: find-unit-suffix ( suffixes n multiplier base -- i/f )
-    suffixes length
-    [ [ n ] dip multiplier base threshhold < ] find-integer
-   suffixes length or 1 [-] ;
+    suffixes length [
+        [ [ n ] dip multiplier base threshhold < ] find-integer
+    ] keep or 1 [-] ;
 
 :: reduce-magnitude ( n multiplier base suffixes -- string )
     n 0 < [