layouts: speed up ``M\ iota hashcode*`` using most-positive-fixnum.

db4
John Benediktsson 2013-03-03 17:33:35 -08:00
parent be7c981462
commit 668d37fef7
2 changed files with 14 additions and 3 deletions

View File

@ -201,8 +201,6 @@ M: reversed hashcode* [ sequence-hashcode ] recursive-hashcode ;
M: slice hashcode* [ sequence-hashcode ] recursive-hashcode ;
M: iota hashcode* over 0 <= [ 2drop 0 ] [ sequence-hashcode ] if ;
M: hashtable hashcode*
[
dup assoc-size 1 eq?

View File

@ -1,7 +1,7 @@
! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces math words kernel assocs classes
math.order kernel.private ;
math.order kernel.private sequences sequences.private ;
IN: layouts
SYMBOL: data-alignment
@ -91,4 +91,17 @@ M: real >integer
dup most-negative-fixnum most-positive-fixnum between?
[ >fixnum ] [ >bignum ] if ; inline
! we put this here so that it can use the references to
! most-positive-fixnum otherwise would be in combinatrs
M: iota hashcode*
over 0 <= [ 2drop 0 ] [
nip length [
0 most-positive-fixnum clamp integer>fixnum
0 swap [ sequence-hashcode-step ] each-integer
] [
most-positive-fixnum swap
[ sequence-hashcode-step ] (each-integer)
] bi
] if ;
UNION: immediate fixnum POSTPONE: f ;