fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 921a0368b3bbe80ff2ca64ebe02c2d12b9729c64 parent ea5341561a6c30a41dd31faf931e33716699e021 Author: John Hawthorn <john.hawthorn@gmail.com> Date: Tue, 15 Jul 2014 00:37:47 -0700 Skip calculate_score for long candidates Diffstat:
| M | match.c | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/match.c b/match.c @@ -31,9 +31,21 @@ void mat_print(int *mat, int n, int m){ typedef int score_t; double calculate_score(const char *needle, const char *haystack){ + if(!*haystack || !*needle) + return SCORE_MIN; + int n = strlen(needle); int m = strlen(haystack); + if(m > 1024){ + /* + * Unreasonably large candidate: return no score + * If it is a valid match it will still be returned, it will + * just be ranked below any reasonably sized candidates + */ + return 0; + } + int bow[m]; int D[n][m], M[n][m]; bzero(D, sizeof(D));