]> gitweb.factorcode.org Git - factor.git/blobdiff - core/sequences/sequences.factor
Revert "sequences: change to use tuple-hashcode algorithm, make string-hashcode work...
[factor.git] / core / sequences / sequences.factor
index 942df32852c24c7a682043ada94d633d1262dd35..153ef91809238af1f4da8683a759d3644518bf47 100644 (file)
@@ -600,14 +600,18 @@ ERROR: assert-sequence got expected ;
 : assert-sequence= ( a b -- )
     2dup sequence= [ 2drop ] [ assert-sequence ] if ;
 
-: sequence-hashcode ( depth seq -- hash )
-    [
-        [ drop 1000003 HEX: 345678 ] dip length
-        [ dup fixnum+fast 82520 fixnum+fast ] [ iota ] bi
-    ] 2keep [
-        swapd nth-unsafe hashcode* rot fixnum-bitxor
-        pick fixnum*fast [ [ fixnum+fast ] keep ] dip swap
-    ] 2curry each drop nip 97531 fixnum+fast ; inline
+<PRIVATE
+
+: sequence-hashcode-step ( oldhash newpart -- newhash )
+    >fixnum swap [
+        [ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
+        fixnum+fast fixnum+fast
+    ] keep fixnum-bitxor ; inline
+
+PRIVATE>
+
+: sequence-hashcode ( n seq -- x )
+    [ 0 ] 2dip [ hashcode* sequence-hashcode-step ] with each ; inline
 
 M: reversed equal? over reversed? [ sequence= ] [ 2drop f ] if ;