]> gitweb.factorcode.org Git - factor.git/commitdiff
add some math.parser hints that slightly improve number parsing performance
authorJoe Groff <arcata@gmail.com>
Mon, 26 Oct 2009 22:48:05 +0000 (17:48 -0500)
committerJoe Groff <arcata@gmail.com>
Mon, 26 Oct 2009 22:48:05 +0000 (17:48 -0500)
basis/hints/hints.factor
core/math/parser/parser.factor

index 496c651fde7d0e7f60eab5c11d2fd3fa6671f7c4..738a960b4b6ab8097aeb1f587c2a006fecb3d7ca 100644 (file)
@@ -3,8 +3,9 @@
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions effects fry generic generic.single
 generic.standard hashtables io.binary io.streams.string kernel
-kernel.private math math.parser namespaces parser sbufs
-sequences splitting splitting.private strings vectors words ;
+kernel.private math math.parser math.parser.private namespaces
+parser sbufs sequences splitting splitting.private strings
+vectors words ;
 IN: hints
 
 GENERIC: specializer-predicate ( spec -- quot )
@@ -133,3 +134,10 @@ SYNTAX: HINTS:
 M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-prop
 
 M\ hashtable set-at { { object fixnum object } { object word object } } "specializer" set-word-prop
+
+\ dec>float { string } "specializer" set-word-prop
+
+\ hex>float { string } "specializer" set-word-prop
+
+\ string>integer { string fixnum } "specializer" set-word-prop
+
index 60fb5559c5a07fc7c4e5e847a1a4a66f5e5e1bb7..9bf1e6a896583c4a3439b69722e0b3702f12dfb4 100644 (file)
@@ -66,10 +66,10 @@ SYMBOL: negative?
     0 over push B{ } like (string>float) ;
 
 : hex>float-parts ( str -- neg? mantissa-str expt )
-    "-" ?head swap "p" split1 [ 10 base> ] [ 0 ] if* ;
+    "-" ?head swap "p" split1 [ 10 base> ] [ 0 ] if* ; inline
 
 : make-mantissa ( str -- bits )
-    16 base> dup log2 52 swap - shift ;
+    16 base> dup log2 52 swap - shift ; inline
 
 : combine-hex-float-parts ( neg? mantissa expt -- float )
     dup 2046 > [ 2drop -1/0. 1/0. ? ] [
@@ -78,7 +78,7 @@ SYMBOL: negative?
         [ 52 2^ 1 - bitand ]
         [ 52 shift ] tri* bitor bitor
         bits>double 
-    ] if ;
+    ] if ; inline
 
 : hex>float ( str -- n/f )
     hex>float-parts