From 3bc658e8d5b1cee4083a5fa114b1a8f6754dbb35 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 7 Apr 2013 12:45:38 -0700 Subject: [PATCH] hashtables.wrapped: faster >alist, keys, values. --- basis/hashtables/wrapped/wrapped.factor | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/basis/hashtables/wrapped/wrapped.factor b/basis/hashtables/wrapped/wrapped.factor index d2ed473ac1..5e35c9c513 100644 --- a/basis/hashtables/wrapped/wrapped.factor +++ b/basis/hashtables/wrapped/wrapped.factor @@ -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 ;