diff options
author | bunnei <bunneidev@gmail.com> | 2023-07-10 18:54:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 18:54:19 -0700 |
commit | ce7c418e0cc05d92c18ad69c7cb37fecfa71b037 (patch) | |
tree | ea1852111c1b3c3c340608ae518fc8711a4fcfe3 /src/common/scratch_buffer.h | |
parent | 169b198d084b925d3ad7048e939e8d25a83a34b8 (diff) | |
parent | f1cfd9c2197e3e0c8409b869714b599d96e079c0 (diff) |
Merge pull request #10996 from Kelebek1/readblock_optimisation
Use spans over guest memory where possible instead of copying data
Diffstat (limited to 'src/common/scratch_buffer.h')
-rw-r--r-- | src/common/scratch_buffer.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/common/scratch_buffer.h b/src/common/scratch_buffer.h index d5961b020..2a98cda53 100644 --- a/src/common/scratch_buffer.h +++ b/src/common/scratch_buffer.h @@ -40,8 +40,21 @@ public: ~ScratchBuffer() = default; ScratchBuffer(const ScratchBuffer&) = delete; ScratchBuffer& operator=(const ScratchBuffer&) = delete; - ScratchBuffer(ScratchBuffer&&) = default; - ScratchBuffer& operator=(ScratchBuffer&&) = default; + + ScratchBuffer(ScratchBuffer&& other) noexcept { + swap(other); + other.last_requested_size = 0; + other.buffer_capacity = 0; + other.buffer.reset(); + } + + ScratchBuffer& operator=(ScratchBuffer&& other) noexcept { + swap(other); + other.last_requested_size = 0; + other.buffer_capacity = 0; + other.buffer.reset(); + return *this; + } /// This will only grow the buffer's capacity if size is greater than the current capacity. /// The previously held data will remain intact. |