| ... | ... |
@@ -111,6 +111,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio |
| 111 | 111 |
|
| 112 | 112 |
for(int i = 0; i < n; i++){
|
| 113 | 113 |
double prev_score = SCORE_MIN; |
| 114 |
+ double gap_score = i == n-1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; |
|
| 114 | 115 |
for(int j = 0; j < m; j++){
|
| 115 | 116 |
score_t score = SCORE_MIN; |
| 116 | 117 |
if(tolower(needle[i]) == tolower(haystack[j])){
|
| ... | ... |
@@ -124,13 +125,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio |
| 124 | 125 |
} |
| 125 | 126 |
} |
| 126 | 127 |
D[i][j] = score; |
| 127 |
- if(j){
|
|
| 128 |
- if(i == n-1){
|
|
| 129 |
- score = max(score, prev_score + SCORE_GAP_TRAILING); |
|
| 130 |
- }else{
|
|
| 131 |
- score = max(score, prev_score + SCORE_GAP_INNER); |
|
| 132 |
- } |
|
| 133 |
- } |
|
| 128 |
+ score = max(score, prev_score + gap_score); |
|
| 134 | 129 |
M[i][j] = score; |
| 135 | 130 |
prev_score = score; |
| 136 | 131 |
} |