diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-15 00:37:47 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-26 20:00:58 -0700 |
commit | 931cf1469a8036f72ab12d792ec820c2fb81cc62 (patch) | |
tree | c6dffa471270219f330bcb6e2513fdae50918cbd /match.c | |
parent | 017bbd0c5661be48c289575ca543f9e31b499b88 (diff) |
Skip calculate_score for long candidates
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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)); |