add some math.parser hints that slightly improve number parsing performance
parent
5caa118e40
commit
ad18098a4f
|
@ -3,8 +3,9 @@
|
||||||
USING: accessors arrays assocs byte-arrays byte-vectors classes
|
USING: accessors arrays assocs byte-arrays byte-vectors classes
|
||||||
combinators definitions effects fry generic generic.single
|
combinators definitions effects fry generic generic.single
|
||||||
generic.standard hashtables io.binary io.streams.string kernel
|
generic.standard hashtables io.binary io.streams.string kernel
|
||||||
kernel.private math math.parser namespaces parser sbufs
|
kernel.private math math.parser math.parser.private namespaces
|
||||||
sequences splitting splitting.private strings vectors words ;
|
parser sbufs sequences splitting splitting.private strings
|
||||||
|
vectors words ;
|
||||||
IN: hints
|
IN: hints
|
||||||
|
|
||||||
GENERIC: specializer-predicate ( spec -- quot )
|
GENERIC: specializer-predicate ( spec -- quot )
|
||||||
|
@ -133,3 +134,10 @@ SYNTAX: HINTS:
|
||||||
M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-prop
|
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
|
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
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,10 @@ SYMBOL: negative?
|
||||||
0 over push B{ } like (string>float) ;
|
0 over push B{ } like (string>float) ;
|
||||||
|
|
||||||
: hex>float-parts ( str -- neg? mantissa-str expt )
|
: 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 )
|
: 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 )
|
: combine-hex-float-parts ( neg? mantissa expt -- float )
|
||||||
dup 2046 > [ 2drop -1/0. 1/0. ? ] [
|
dup 2046 > [ 2drop -1/0. 1/0. ? ] [
|
||||||
|
@ -78,7 +78,7 @@ SYMBOL: negative?
|
||||||
[ 52 2^ 1 - bitand ]
|
[ 52 2^ 1 - bitand ]
|
||||||
[ 52 shift ] tri* bitor bitor
|
[ 52 shift ] tri* bitor bitor
|
||||||
bits>double
|
bits>double
|
||||||
] if ;
|
] if ; inline
|
||||||
|
|
||||||
: hex>float ( str -- n/f )
|
: hex>float ( str -- n/f )
|
||||||
hex>float-parts
|
hex>float-parts
|
||||||
|
|
Loading…
Reference in New Issue