Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow ref byte to point just past the end of spans (#73)
Motivation ---------- I was under the impression that `ref byte` should never point past the end of a `Span<byte>` or `ReadOnlySpan<byte>` because then GC couldn't recognize the pointer and adjust it during GC moves. However, this there is a specific exception that allows `ref byte` to point precisely one byte past the end and still be recognized to allow pointer arithmetic scenarios like the ones in this algorithm. Modifications ------------- Where there is more complex logic (compared to the reference C++ implementation) to allow buffer end pointers to point to the last byte in the buffer simplify this logic and point one byte past the end of the buffer. Also ensure that comparison operations that ensure a certain length don't involve an intermediate pointer that moves off the beginning of the buffer. Results ------- We're now back to closer to the reference C++ implementation but still have memory safety.
- Loading branch information
1 parent
e3c9834
commit d7ac526
Showing
4 changed files
with
45 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters