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 ; parser vocabs.loader ;
IN: hashtables.identity 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? M: identity-wrapper equal?
over identity-wrapper? over identity-wrapper?
[ [ underlying>> ] bi@ eq? ] [ [ underlying>> ] bi@ eq? ]
[ 2drop f ] if ; inline [ 2drop f ] if ; inline
M: identity-wrapper hashcode* M: identity-wrapper hashcode* nip identity-hashcode>> ; inline
nip underlying>> identity-hashcode ; inline
TUPLE: identity-hashtable < wrapped-hashtable ; TUPLE: identity-hashtable < wrapped-hashtable ;