Skip to content

Commit

Permalink
Various buffer optimizations (#1211)
Browse files Browse the repository at this point in the history
This PR is a set of small cleanups to reduce `memcpy` and `memset` calls in
`Buffer` wrangling.

- `Buffer::eat` just swaps pointers if it's a complete (fully owned) overwrite,
  instead of using `memcpy`
- `Buffer::eat` no longer sets the size of the eaten buffer to 0, to avoid
  `memset` when scaling it up later
- Added a new `Buffer:reset_owned`, which resizes and clears the `owned` flags
  but **does not** clear buffer data (for the case where we're about to
  overwrite buffer data anyways)
    - Use this new function in `Volume::read`
- In `Volume::read`, read directly into the provided buffer if there's only one
  subvolume (instead of reading into a scratch buffer then copying)
    - The scratch buffer is no longer always allocated; it's resized if needed
  • Loading branch information
mkeeter authored Mar 21, 2024
1 parent 9adf12f commit c2dfd3f
Show file tree
Hide file tree
Showing 3 changed files with 480 additions and 402 deletions.
Loading

0 comments on commit c2dfd3f

Please sign in to comment.