|
1 | 1 | /* krep - A high-performance string search utility |
2 | 2 | * |
3 | 3 | * Author: Davide Santangelo |
4 | | - * Version: 0.1.1 |
| 4 | + * Version: 0.1.2 |
5 | 5 | * Year: 2025 |
6 | 6 | * |
7 | 7 | * Features: |
@@ -173,7 +173,7 @@ uint64_t boyer_moore_search(const char *text, size_t text_len, |
173 | 173 | } |
174 | 174 | if (match) { |
175 | 175 | match_count++; |
176 | | - i += pattern_len; // changed: skip entire pattern on match |
| 176 | + i++; // Changed: increment by 1 instead of pattern_len to catch all matches |
177 | 177 | } else { |
178 | 178 | unsigned char bad_char = text[i]; |
179 | 179 | if (!case_sensitive) bad_char = tolower(bad_char); |
@@ -254,9 +254,7 @@ uint64_t kmp_search(const char *text, size_t text_len, |
254 | 254 |
|
255 | 255 | if (j == pattern_len) { |
256 | 256 | match_count++; |
257 | | - // Jump ahead by one character (for single-char patterns) or full pattern |
258 | | - // to avoid overlapping |
259 | | - i = i - j + (pattern_len > 1 ? pattern_len : 1); |
| 257 | + i = i - j + 1; |
260 | 258 | j = 0; |
261 | 259 | } |
262 | 260 | } |
@@ -357,7 +355,7 @@ uint64_t simd_search(const char *text, size_t text_len, |
357 | 355 | int um = _mm_cmpestri(up, pattern_len, lt, pattern_len, _SIDD_CMP_EQUAL_ORDERED); |
358 | 356 | if (lm == 0 || um == 0) { |
359 | 357 | match_count++; |
360 | | - i += pattern_len; // Skip ahead to avoid overlapping matches |
| 358 | + i++; |
361 | 359 | } else { |
362 | 360 | i++; |
363 | 361 | } |
@@ -430,7 +428,7 @@ uint64_t avx2_search(const char *text, size_t text_len, |
430 | 428 |
|
431 | 429 | if (match) { |
432 | 430 | match_count++; |
433 | | - i += pattern_len; // Skip ahead to avoid overlapping matches |
| 431 | + i++; // Changed: increment by 1 instead of pattern_len to catch all matches |
434 | 432 | } else { |
435 | 433 | i++; |
436 | 434 | } |
|
0 commit comments