-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
Description
Which approach is best?
AndEq
approach, used by internal and public Microsoft helpers:
static bool AndEq(byte[] a, byte[] b)
{
bool f = a.Length == b.Length;
for (int i = 0; i < a.Length && i < b.Length; ++i)
{
f &= a[i] == b[i];
}
return f;
}
OrXor
approach (classic):
static bool OrXor(byte[] a, byte[] b)
{
int x = a.Length ^ b.Length;
for (int i = 0; i < a.Length && i < b.Length; ++i)
{
x |= a[i] ^ b[i];
}
return x == 0;
}
OrSub
approach, recently advocated by Microsoft as the "better way" (no supporting evidence):
static bool OrSub(byte[] a, byte[] b)
{
int x = a.Length ^ b.Length;
for (int i = 0; i < a.Length && i < b.Length; ++i)
{
x |= a[i] - b[i];
}
return x == 0;
}
Some other approach?