hashtables.identity: cache the identity hashcode on the wrapper.

db4
John Benediktsson 2012-07-17 16:04:27 -07:00
parent 72de9badda
commit 6a08de2203
1 changed files with 4 additions and 4 deletions

View File

@ -3,17 +3,17 @@ USING: accessors assocs hashtables hashtables.wrapped kernel
parser vocabs.loader ;
IN: hashtables.identity
TUPLE: identity-wrapper < wrapped-key ;
TUPLE: identity-wrapper < wrapped-key identity-hashcode ;
C: <identity-wrapper> identity-wrapper
: <identity-wrapper> ( wrapped-key -- identity-wrapper )
dup identity-hashcode identity-wrapper boa ; inline
M: identity-wrapper equal?
over identity-wrapper?
[ [ underlying>> ] bi@ eq? ]
[ 2drop f ] if ; inline
M: identity-wrapper hashcode*
nip underlying>> identity-hashcode ; inline
M: identity-wrapper hashcode* nip identity-hashcode>> ; inline
TUPLE: identity-hashtable < wrapped-hashtable ;