fzy

terminal fuzzy finder picker

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

commit ffa039f7c422ffc53664d204f386dedbf254ae46
parent d34c7a33b3a0d5bd5e9e53130bbce16c631a9c78
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Mon, 22 Sep 2014 00:30:29 -0700

Prefer score_t over double

Diffstat:
Mmatch.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/match.c b/match.c @@ -50,7 +50,7 @@ void mat_print(score_t *mat, const char *needle, const char *haystack){ fprintf(stderr, "\n\n"); } -double calculate_score(const char *needle, const char *haystack, size_t *positions){ +score_t calculate_score(const char *needle, const char *haystack, size_t *positions){ if(!*haystack || !*needle) return SCORE_MIN; @@ -102,8 +102,8 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio } for(int i = 0; i < n; i++){ - double prev_score = SCORE_MIN; - double gap_score = i == n-1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; + score_t prev_score = SCORE_MIN; + score_t gap_score = i == n-1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; for(int j = 0; j < m; j++){ score_t score = SCORE_MIN; if(tolower(needle[i]) == tolower(haystack[j])){ @@ -159,7 +159,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio return M[n-1][m-1]; } -double match_positions(const char *needle, const char *haystack, size_t *positions){ +score_t match_positions(const char *needle, const char *haystack, size_t *positions){ if(!*needle){ return SCORE_MAX; }else if(!strcasecmp(needle, haystack)){ @@ -174,6 +174,6 @@ double match_positions(const char *needle, const char *haystack, size_t *positio } } -double match(const char *needle, const char *haystack){ +score_t match(const char *needle, const char *haystack){ return match_positions(needle, haystack, NULL); }