]> gitweb.factorcode.org Git - factor.git/commitdiff
strings: embed sequence-hashcode algorithm in rehash-string.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 18 Dec 2020 15:23:19 +0000 (07:23 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 18 Dec 2020 15:23:19 +0000 (07:23 -0800)
This allows us to experiment with changing sequence-hashcode.  For some
reason there is an issue with changing the hashcode algorithm for
strings when bootstrapping, the current rehash approach in stage1
doesn't rehash strings, but even when we do that, its still not quite
working right yet.

core/strings/strings.factor

index 0a6d1b8a62e3d4e16dc85edbcb1f4580ec26c8b0..e14dc89592ab6eb251578c19b0289d075468d42d 100644 (file)
@@ -22,7 +22,12 @@ PRIMITIVE: string-nth-fast ( n string -- ch )
     f swap set-string-hashcode ; inline
 
 : rehash-string ( str -- )
-    1 over sequence-hashcode swap set-string-hashcode ; inline
+    0 over [
+        swap [
+            [ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
+            fixnum+fast fixnum+fast
+        ] keep fixnum-bitxor
+    ] each swap set-string-hashcode ; inline
 
 : (aux) ( n string -- byte-array m )
     aux>> { byte-array } declare swap 1 fixnum-shift-fast ; inline