]> gitweb.factorcode.org Git - factor.git/commitdiff
words: since word names can be tuples (i'm looking at you smalltalk), use a combining...
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Oct 2011 01:42:55 +0000 (18:42 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Oct 2011 01:46:49 +0000 (18:46 -0700)
core/words/words.factor

index c791829ede3ed8d2fdca87c4ebb89a4b77a99498..80bb7fc7f765a6796592f25602c2cf1fb099f240 100644 (file)
@@ -168,8 +168,21 @@ 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 swap ":" glue hashcode >fixnum (word) dup new-word ;
+    2dup 2hash >fixnum (word) dup new-word ;
 
 : <uninterned-word> ( name -- word )
     f \ <uninterned-word> counter >fixnum (word)