diff options
author | bunnei <bunneidev@gmail.com> | 2020-11-19 12:39:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 12:39:38 -0800 |
commit | 6971d088939a86b3e4cf477168be8f2592679323 (patch) | |
tree | 2423f639b1713380aab4196d0abb682789416c49 | |
parent | 92344da20ce4801543c1d3148e1f1b62ba162ffb (diff) | |
parent | 412044960a39180bc9990f6b35e1872c6a69591b (diff) |
Merge pull request #4948 from lioncash/page-resize
virtual_buffer: Do nothing on resize() calls with same sizes
-rw-r--r-- | src/common/virtual_buffer.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 078e61c77..91d430036 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -43,9 +43,14 @@ public: } void resize(std::size_t count) { + const auto new_size = count * sizeof(T); + if (new_size == alloc_size) { + return; + } + FreeMemoryPages(base_ptr, alloc_size); - alloc_size = count * sizeof(T); + alloc_size = new_size; base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); } |