fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 73187cac1fc962d582f5dffe42d48936bffd70f3
parent 7396d08a074f61cdb0fa7f3d38bd952d22886139
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Tue,  7 Jun 2016 02:03:48 -0700

Skip sorting on empty search string

For the empty query, sorting can be the slowest part of the search.
Since the empty query gives no scores, and we've now made our sort
stable, in this case we can simply skip sorting.

A sort of 250000 entries took about ~10ms on my laptop, which is not a
huge amount. However it's not 0 and is free to skip.

Diffstat:
Msrc/choices.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/choices.c b/src/choices.c @@ -151,7 +151,9 @@ void choices_search(choices_t *c, const char *search) { } } - qsort(c->results, c->available, sizeof(struct scored_result), cmpchoice); + if(*search) { + qsort(c->results, c->available, sizeof(struct scored_result), cmpchoice); + } } const char *choices_get(choices_t *c, size_t n) {