Skip to content
Snippets Groups Projects
Commit 41204496 authored by Lioncash's avatar Lioncash
Browse files

virtual_buffer: Do nothing on resize() calls with same sizes

Prevents us from churning memory by freeing and reallocating a memory
block that would have already been adequate as is.
parent 92344da2
No related branches found
No related tags found
No related merge requests found
......@@ -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));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment