Use offset as a variable in the search

Makes the search not repeat itself.
This commit is contained in:
Kurt 2015-09-23 19:09:48 -07:00
parent bfd7aef6be
commit 8649dd958f

View File

@ -91,8 +91,8 @@ internal static void ReplaceAllBytes(byte[] array, byte[] oldPattern, byte[] new
{
if (oldPattern.Length != newPattern.Length || oldPattern.SequenceEqual(newPattern))
return;
int offset; // Loop until no instances of oldPattern are found
while ((offset = IndexOfBytes(array, oldPattern, 0, 0)) != -1)
int offset = 0; // Loop until no instances of oldPattern are found
while ((offset = IndexOfBytes(array, oldPattern, offset, 0)) != -1)
Array.Copy(newPattern, 0, array, offset, newPattern.Length);
}
}