fzy

terminal fuzzy finder picker

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

commit 2c0ad46e24c2b5c4cbc5af2d047fcbfa583b0d59
parent 76151226b7cfa39582bad17058c70c41ac467673
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Sat,  6 Sep 2014 18:04:10 -0700

Avoid unnecessary matrix access

Diffstat:
Mmatch.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/match.c b/match.c @@ -110,6 +110,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio } for(int i = 0; i < n; i++){ + double prev_score = SCORE_MIN; for(int j = 0; j < m; j++){ score_t score = SCORE_MIN; if(tolower(needle[i]) == tolower(haystack[j])){ @@ -125,12 +126,13 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio D[i][j] = score; if(j){ if(i == n-1){ - score = max(score, M[i][j-1] + SCORE_GAP_TRAILING); + score = max(score, prev_score + SCORE_GAP_TRAILING); }else{ - score = max(score, M[i][j-1] + SCORE_GAP_INNER); + score = max(score, prev_score + SCORE_GAP_INNER); } } M[i][j] = score; + prev_score = score; } }