tools.completion: speed up apropos by 35%. Fixes #101.
parent
b653360299
commit
5e496e846b
|
@ -8,8 +8,14 @@ vocabs.hierarchy words ;
|
||||||
|
|
||||||
IN: tools.completion
|
IN: tools.completion
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: smart-index-from ( obj i seq -- n/f )
|
||||||
|
rot [ ch>lower ] [ ch>upper ] bi
|
||||||
|
[ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ;
|
||||||
|
|
||||||
:: (fuzzy) ( accum i full ch -- accum i full ? )
|
:: (fuzzy) ( accum i full ch -- accum i full ? )
|
||||||
ch i full index-from [
|
ch i full smart-index-from [
|
||||||
:> i i accum push
|
:> i i accum push
|
||||||
accum i 1 + full t
|
accum i 1 + full t
|
||||||
] [
|
] [
|
||||||
|
@ -64,14 +70,16 @@ IN: tools.completion
|
||||||
dupd fuzzy score max ;
|
dupd fuzzy score max ;
|
||||||
|
|
||||||
: completion ( short candidate -- result )
|
: completion ( short candidate -- result )
|
||||||
[ second >lower swap complete ] keep 2array ;
|
[ second swap complete ] keep 2array ;
|
||||||
|
|
||||||
: completion, ( short candidate -- )
|
: completion, ( short candidate -- )
|
||||||
completion dup first 0 > [ , ] [ drop ] if ;
|
completion dup first 0 > [ , ] [ drop ] if ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
: completions ( short candidates -- seq )
|
: completions ( short candidates -- seq )
|
||||||
[ ] [
|
[ ] [
|
||||||
[ >lower ] dip [ [ completion, ] with each ] { } make
|
[ [ completion, ] with each ] { } make
|
||||||
rank-completions
|
rank-completions
|
||||||
] bi-curry if-empty ;
|
] bi-curry if-empty ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue