]> gitweb.factorcode.org Git - factor.git/commitdiff
layouts: speed up ``M\ iota hashcode*`` using most-positive-fixnum.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Mar 2013 01:33:35 +0000 (17:33 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Mar 2013 01:33:35 +0000 (17:33 -0800)
core/combinators/combinators.factor
core/layouts/layouts.factor

index de6616d76f923be3a1fe520b9f7189b9a9f9e0c8..1a76bcc70ece7b34d8640394942bb7bd9cc3d279 100644 (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?
index 643e5c221a92c023affcb2b9c6807e4caebb5a9a..a7bfbb7c2ddc396237d1f69a401f1cdad4a25fd9 100644 (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 ;