]> gitweb.factorcode.org Git - factor.git/commitdiff
words: change word hash to do less work.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 9 Jun 2015 23:08:48 +0000 (16:08 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 9 Jun 2015 23:08:48 +0000 (16:08 -0700)
core/hashtables/hashtables.factor
core/words/words.factor

index a8c8fc52cbe816d927c56e916ecc77aa61dcda00..9da1d96ecb602e5d9d1e223d4210916bbf51a170 100644 (file)
@@ -187,9 +187,11 @@ M: hashtable assoc-like
 ! 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 0x13c6ef37 + ] dip
-    [ 6 shift ] [ -2 shift ] bi + + ;
+: hash-combine ( hash1 hash2 -- newhash )
+    [ 0x13c6ef37 + ] dip [ 6 shift ] [ -2 shift ] bi + + ; inline
+
+: 2hashcode ( obj1 obj2 -- hash )
+    [ hashcode ] bi@ hash-combine ; inline
 
 ERROR: malformed-hashtable-pair seq pair ;
 
index 0be414ad000216ed6060be790ba43b6114c36df9..21549daa6bbc46806e84dfd30ee2f7b39784a988 100644 (file)
@@ -188,7 +188,7 @@ M: word reset-word
     ] tri ;
 
 : <word> ( name vocab -- word )
-    2dup 0 hash-combine hash-combine >fixnum (word) dup new-word ;
+    2dup 2hashcode >fixnum (word) dup new-word ;
 
 : <uninterned-word> ( name -- word )
     f \ <uninterned-word> counter >fixnum (word)
@@ -202,8 +202,7 @@ M: word reset-word
 
 : reveal ( word -- )
     dup [ name>> ] [ vocabulary>> ] bi dup vocab-words-assoc
-    [ ] [ no-vocab ] ?if
-    set-at ;
+    [ ] [ no-vocab ] ?if set-at ;
 
 ERROR: bad-create name vocab ;