| ... | ... |
@@ -118,16 +118,16 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio |
| 118 | 118 |
if(!i){
|
| 119 | 119 |
score = (j * SCORE_GAP_LEADING) + match_bonus[j]; |
| 120 | 120 |
}else if(j){
|
| 121 |
- score = max(score, M[i-1][j-1] + match_bonus[j]); |
|
| 121 |
+ score = max( |
|
| 122 |
+ M[i-1][j-1] + match_bonus[j], |
|
| 122 | 123 |
|
| 123 |
- /* consecutive match, doesn't stack with match_bonus */ |
|
| 124 |
- score = max(score, D[i-1][j-1] + SCORE_MATCH_CONSECUTIVE); |
|
| 124 |
+ /* consecutive match, doesn't stack with match_bonus */ |
|
| 125 |
+ D[i-1][j-1] + SCORE_MATCH_CONSECUTIVE |
|
| 126 |
+ ); |
|
| 125 | 127 |
} |
| 126 | 128 |
} |
| 127 | 129 |
D[i][j] = score; |
| 128 |
- score = max(score, prev_score + gap_score); |
|
| 129 |
- M[i][j] = score; |
|
| 130 |
- prev_score = score; |
|
| 130 |
+ M[i][j] = prev_score = max(score, prev_score + gap_score); |
|
| 131 | 131 |
} |
| 132 | 132 |
} |
| 133 | 133 |
|