2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

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.
This commit is contained in:
Lioncash 2020-11-19 07:54:00 -05:00
parent 92344da20c
commit 412044960a

View file

@ -43,9 +43,14 @@ public:
} }
void resize(std::size_t count) { void resize(std::size_t count) {
const auto new_size = count * sizeof(T);
if (new_size == alloc_size) {
return;
}
FreeMemoryPages(base_ptr, alloc_size); FreeMemoryPages(base_ptr, alloc_size);
alloc_size = count * sizeof(T); alloc_size = new_size;
base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size));
} }