words: change word hash to do less work.

db4
John Benediktsson 2015-06-09 16:08:48 -07:00
parent aa00d59d59
commit 6210edf76e
2 changed files with 7 additions and 6 deletions

View 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 ;

View 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 ;