From 693dd717c4d74fdff78d5813323c146aecf926b8 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 19 Jun 2012 13:50:50 -0700 Subject: [PATCH] tools.completion: 5-7% performance improvement. --- basis/tools/completion/completion.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/basis/tools/completion/completion.factor b/basis/tools/completion/completion.factor index c2265b2981..40048409d0 100644 --- a/basis/tools/completion/completion.factor +++ b/basis/tools/completion/completion.factor @@ -12,21 +12,21 @@ IN: tools.completion : smart-index-from ( obj i seq -- n/f ) rot [ ch>lower ] [ ch>upper ] bi - [ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ; + '[ dup _ eq? [ drop t ] [ _ eq? ] if ] find-from drop ; PRIVATE> -:: (fuzzy) ( accum i full ch -- accum i full ? ) +:: (fuzzy) ( accum i full ch -- accum i ? ) ch i full smart-index-from [ - :> i i accum push - accum i 1 + full t + [ accum push ] + [ accum swap 1 + t ] bi ] [ - f -1 full f + f -1 f ] if* ; : fuzzy ( full short -- indices ) dup [ length 0 ] curry 2dip - [ (fuzzy) ] all? 3drop ; + [ (fuzzy) ] with all? 2drop ; : (runs) ( runs n seq -- runs n ) [ @@ -38,7 +38,7 @@ PRIVATE> ] each ; : runs ( seq -- newseq ) - V{ V{ } } [ clone ] map over first rot (runs) drop ; + [ V{ } clone 1vector ] dip [ first ] keep (runs) drop ; : score-1 ( i full -- n ) {