// TODO: PERF make this do 3 blocks 8 bytes at once for better perf // TODO: PERF use HashCode.Add not Combine private static uint Crc32CElseHashCodeCombine(byte *first, nuint length) { uint value = ~0u; var leadingBytes = MathHelpers.AlignUp(first, 8); // handle leading bytes until 8 byte aligned while (first < leadingBytes) { value = Hash(value, *first++); length--; } ulong *pLong = (ulong *)first; byte * last = first + length; byte * alignedLast = first + MathHelpers.AlignDown(length, 8); // handle main in 8 byte chunks until we can't anymore ulong tmpValue = value; while (pLong < alignedLast) { tmpValue = Hash8(tmpValue, *pLong++); } value = (uint)tmpValue; // handle trailing first = (byte *)pLong; while (first < last) { value = Hash(value, *first++); } return(value);