We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 0f9730f + e53d24b commit 67d2d02Copy full SHA for 67d2d02
1 file changed
Boyer_Moore_Horspool/C#/Davipb/Horspool.cs
@@ -32,7 +32,7 @@ public static int Find(string haystack, string needle)
32
33
int index = 0;
34
35
- while (index <= haystack.Length - needle.Length)
+ while (index < haystack.Length - needle.Length)
36
{
37
bool match = true;
38
@@ -42,6 +42,10 @@ public static int Find(string haystack, string needle)
42
43
match = false;
44
index += BadMatchTable[haystack[index + needle.Length - 1]];
45
+ if (index >= haystack.Length)
46
+ {
47
+ break;
48
+ }
49
}
50
51
0 commit comments