The code in question (below) reads much faster (30x), tahn regular: MemoryMappedViewAccessor.ReadArray() I'm trying to modify the code to be able to read from long offset, not int (!)
public unsafe byte[] ReadBytes(int offset, int num)
{
byte[] arr = new byte[num];
byte *ptr = (byte*)0;
this._view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
Marshal.Copy(IntPtr.Add(new IntPtr(ptr), offset), arr, 0, num);
this._view.SafeMemoryMappedViewHandle.ReleasePointer();
return arr;
}
original code is here: How can I quickly read bytes from a memory mapped file in .NET?_
I need to adjust IntPtr.Add and Marshal.Copy to correctly work with long offset Thank you in advance!