Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix From<AlignedVec> for AlignedBytes (openzfs#55)
When a Vec is converted to Bytes, the excess capacity of the Vec is dropped, by reallocating the Vec to be smaller and freeing the old memory. When the Vec of an AlignedVec is converted to Bytes, we don't want this to happen, becuase the new allocation won't necessarily have the same alignment as the Vec's old buffer. Also it has a performance impact of an additional alloc/bcopy/free, which is what we're trying to avoid with the AlignedVec. We can avoid this by setting the Vec's size the be the same as its capacity before conversion. We also verify that it's buffer pointer doesn't change across these operations.
- Loading branch information