nickbabcock/Farmhash.Sharp

Investigate Spans

nickbabcock opened this issue · 2 comments

I'm afraid that grabbing the next 64bits in a Span won't be as efficient as:

ulong Fetch64(byte* p) => *(ulong*)p

Even though a Span is a contiguous area of memory, I'm not sure if there's an operation that is as similarly optimized as pointers.

Actually, it may be doable.

  1. Wait for .NET Core 2.1
  2. Use MemoryMarshal.GetReference, to get a reference to the first element of the span.
  3. Unsafe.As cast from reference to pointer.
  4. Use the byte* methods

Added in 0.6