public static bool Equals(IChannelBuffer bufferA, IChannelBuffer bufferB) { int aLen = bufferA.ReadableBytes; if (aLen != bufferB.ReadableBytes) { return(false); } int byteCount = aLen & 7; int aIndex = bufferA.ReaderIndex; int bIndex = bufferB.ReaderIndex; for (int i = byteCount; i > 0; i--) { if (bufferA.GetByte(aIndex) != bufferB.GetByte(bIndex)) { return(false); } aIndex++; bIndex++; } return(true); }
public static int Compare(IChannelBuffer bufferA, IChannelBuffer bufferB) { int aLen = bufferA.ReadableBytes; int bLen = bufferB.ReadableBytes; int minLength = Math.Min(aLen, bLen); int aIndex = bufferA.ReaderIndex; int bIndex = bufferB.ReaderIndex; for (int i = minLength; i > 0; i--) { byte va = bufferA.GetByte(aIndex); byte vb = bufferB.GetByte(bIndex); if (va > vb) { return(1); } else if (va < vb) { return(-1); } aIndex++; bIndex++; } return(aLen - bLen); }