hashtables.wrapped: faster >alist, keys, values.

db4
John Benediktsson 2013-04-07 12:45:38 -07:00
parent 17da9e0cff
commit 3bc658e8d5
1 changed files with 10 additions and 2 deletions

View File

@ -3,7 +3,7 @@
USING: accessors arrays assocs hashtables kernel sequences
vocabs.loader ;
FROM: sequences => change-nth ;
IN: hashtables.wrapped
TUPLE: wrapped-key
@ -37,7 +37,15 @@ M: wrapped-hashtable set-at
wrapper@ set-at ; inline
M: wrapped-hashtable >alist
underlying>> >alist [ [ first underlying>> ] [ second ] bi 2array ] map ;
underlying>> >alist [
[ 0 swap [ underlying>> ] change-nth ] each
] keep ;
M: wrapped-hashtable keys
underlying>> keys [ underlying>> ] map! ;
M: wrapped-hashtable values
underlying>> values ;
M: wrapped-hashtable equal?
over wrapped-hashtable? [ [ underlying>> ] same? ] [ 2drop f ] if ;