1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-12-22 16:42:46 +01:00
Brotli-Builder/BrotliImpl/Utils/Match.cs

28 lines
786 B
C#

using System;
namespace BrotliImpl.Utils{
static class Match{
public static bool Check(in ArraySegment<byte> bytes, int current, int candidate, int length){
for(int offset = 0; offset < length; offset++){
if (bytes[current + offset] != bytes[candidate + offset]){
return false;
}
}
return true;
}
public static int DetermineLength(in ArraySegment<byte> bytes, int current, int candidate, int limit){
int matched = 0;
while(matched < limit && bytes[current] == bytes[candidate]){
++current;
++candidate;
++matched;
}
return matched;
}
}
}