示例#1
0
        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));
        }
示例#2
0
文件: Slice.cs 项目: dkardach/ravendb
        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());
        }
示例#3
0
 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));
 }