From 8ea195d8ce8693e1b892c65fa1864272a472caa3 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sat, 29 Mar 2008 16:08:08 -0600 Subject: [PATCH] hashtables: use cleavers in hashtables --- core/hashtables/hashtables.factor | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/hashtables/hashtables.factor b/core/hashtables/hashtables.factor index 7d8c6f0b5f..1fabc1aab7 100755 --- a/core/hashtables/hashtables.factor +++ b/core/hashtables/hashtables.factor @@ -95,11 +95,12 @@ IN: hashtables [ swap pick (set-hash) drop f ] find-pair 2drop 2drop ; : hash-large? ( hash -- ? ) - dup hash-count 3 fixnum*fast - swap hash-array array-capacity > ; + [ hash-count 3 fixnum*fast ] + [ hash-array array-capacity ] bi > ; : hash-stale? ( hash -- ? ) - dup hash-deleted 10 fixnum*fast swap hash-count fixnum> ; + [ hash-deleted 10 fixnum*fast ] + [ hash-count ] bi fixnum> ; : grow-hash ( hash -- ) [ dup hash-array swap assoc-size 1+ ] keep @@ -183,10 +184,13 @@ M: hashtable assoc-like [ 3drop ] [ dupd dupd set-at swap push ] if ; inline : prune ( seq -- newseq ) - dup length over length - rot [ >r 2dup r> (prune) ] each nip ; + [ length ] + [ length ] + [ ] tri + [ >r 2dup r> (prune) ] each nip ; : all-unique? ( seq -- ? ) - dup prune [ length ] 2apply = ; + [ length ] + [ prune length ] bi = ; INSTANCE: hashtable assoc