]> gitweb.factorcode.org Git - factor.git/commitdiff
hashtables: moving hash-combine to hashtables.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Oct 2011 03:28:51 +0000 (20:28 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Oct 2011 03:29:49 +0000 (20:29 -0700)
core/hashtables/hashtables.factor
core/words/words.factor

index 98218ecbe81ee533d7d5e7ebdef19564387e0811..7883b2dfb9e3a5ce33e3593371f7dcbd2785631f 100644 (file)
@@ -167,4 +167,11 @@ M: hashtable assoc-like
 : ?set-at ( value key assoc/f -- assoc )
     [ [ set-at ] keep ] [ associate ] if* ;
 
+! borrowed from boost::hash_combine, but the
+! magic number is 2^29/phi instead of 2^32/phi
+! due to max fixnum value on 32-bit machines
+: hash-combine ( obj oldhash -- newhash )
+    [ hashcode HEX: 13c6ef37 + ] dip
+    [ 6 shift ] [ -2 shift ] bi + + ;
+
 INSTANCE: hashtable assoc
index 80bb7fc7f765a6796592f25602c2cf1fb099f240..56503d36920d180c06f789133a9685cd8b542ae3 100644 (file)
@@ -168,21 +168,8 @@ M: word reset-word
         } reset-props
     ] tri ;
 
-<PRIVATE
-
-! borrowed from boost::hash_combine, but the
-! magic number is 2^29/phi instead of 2^32/phi
-! due to max fixnum value on 32-bit machines
-: hash-combine ( hash seed -- newhash )
-    [ HEX: 13c6ef37 + ] dip [ 6 shift ] [ -2 shift ] bi + + ;
-
-: 2hash ( obj1 obj2 -- hash )
-    [ hashcode ] bi@ 0 hash-combine hash-combine ;
-
-PRIVATE>
-
 : <word> ( name vocab -- word )
-    2dup 2hash >fixnum (word) dup new-word ;
+    2dup 0 hash-combine hash-combine >fixnum (word) dup new-word ;
 
 : <uninterned-word> ( name -- word )
     f \ <uninterned-word> counter >fixnum (word)