private int CompareData(ValueReader other, int len) { if (_buffer != null) { fixed(byte *a = _buffer) { if (other._buffer != null) { fixed(byte *b = other._buffer) { return(MemoryUtils.Compare(a, b, len)); } } return(MemoryUtils.Compare(a, other._val, len)); } } if (other._buffer != null) { fixed(byte *b = other._buffer) { return(MemoryUtils.Compare(_val, b, len)); } } return(MemoryUtils.Compare(_val, other._val, len)); }
protected override int CompareData(MemorySlice other, ushort size) { var otherSlice = other as Slice; if (otherSlice != null) { if (Array != null) { fixed(byte *a = Array) { if (otherSlice.Array != null) { fixed(byte *b = otherSlice.Array) { return(MemoryUtils.Compare(a, b, size)); } } return(MemoryUtils.Compare(a, otherSlice.Pointer, size)); } } if (otherSlice.Array != null) { fixed(byte *b = otherSlice.Array) { return(MemoryUtils.Compare(Pointer, b, size)); } } return(MemoryUtils.Compare(Pointer, otherSlice.Pointer, size)); } var prefixedSlice = other as PrefixedSlice; if (prefixedSlice != null) { return(SliceComparisonMethods.Compare(this, prefixedSlice, MemoryUtils.MemoryComparerInstance, size)); } throw new NotSupportedException("Cannot compare because of unknown slice type: " + other.GetType()); }
private static unsafe void CompareBuffers(byte[] buffer, MemoryStream memoryStream) { fixed(byte *b = buffer) fixed(byte *c = memoryStream.GetBuffer()) Assert.Equal(0, MemoryUtils.Compare(b, c, buffer.Length)); }