fix: optimize reading byte-aligned types from a byte-aligned buffer #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change optimizes reading and writing byte-aligned values (u8, u16, u24, u32) when the buffer is byte-aligned as well.
bench before:
after:
Note that even though we check for byte alignment, due to
chainwe can't assume the bytes we're writing to are contiguous, so even with this change we have copy the data into bytes and then write them viatry_copy_to_slice_bytes/try_put_slice_bytesso the reads/writes will play nicely if the underlying buffer is chained.