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 ! borrowed from boost::hash_combine, but the
! magic number is 2^29/phi instead of 2^32/phi ! magic number is 2^29/phi instead of 2^32/phi
! due to max fixnum value on 32-bit machines ! due to max fixnum value on 32-bit machines
: hash-combine ( obj oldhash -- newhash ) : hash-combine ( hash1 hash2 -- newhash )
[ hashcode 0x13c6ef37 + ] dip [ 0x13c6ef37 + ] dip [ 6 shift ] [ -2 shift ] bi + + ; inline
[ 6 shift ] [ -2 shift ] bi + + ;
: 2hashcode ( obj1 obj2 -- hash )
[ hashcode ] bi@ hash-combine ; inline
ERROR: malformed-hashtable-pair seq pair ; ERROR: malformed-hashtable-pair seq pair ;

View File

@ -188,7 +188,7 @@ M: word reset-word
] tri ; ] tri ;
: <word> ( name vocab -- word ) : <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 ) : <uninterned-word> ( name -- word )
f \ <uninterned-word> counter >fixnum (word) f \ <uninterned-word> counter >fixnum (word)
@ -202,8 +202,7 @@ M: word reset-word
: reveal ( word -- ) : reveal ( word -- )
dup [ name>> ] [ vocabulary>> ] bi dup vocab-words-assoc dup [ name>> ] [ vocabulary>> ] bi dup vocab-words-assoc
[ ] [ no-vocab ] ?if [ ] [ no-vocab ] ?if set-at ;
set-at ;
ERROR: bad-create name vocab ; ERROR: bad-create name vocab ;