From 382639fb3f789bb489691c8b497d112d7e1e7415 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 7 Nov 2017 19:29:16 +0000 Subject: [PATCH] Change rdcarray resize strategy to exponential instead of minimal * Normally this wasn't a problem but in a few cases we were doing lots of push_back calls and this caused horrible resize-by-1 behaviour. * So instead we double the available count (if that's larger than just satisfying the request). --- renderdoc/api/replay/basic_types.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renderdoc/api/replay/basic_types.h b/renderdoc/api/replay/basic_types.h index e0fd53b69..c7f1897de 100644 --- a/renderdoc/api/replay/basic_types.h +++ b/renderdoc/api/replay/basic_types.h @@ -176,7 +176,11 @@ public: if(s <= capacity()) return; - // for now, just resize exactly to what's needed. + // either double, or allocate what's needed, whichever is bigger. ie. by default we double in + // size but we don't grow exponentially in 2^n to cover a single really large resize + if(size_t(allocatedCount) * 2 > s) + s = size_t(allocatedCount) * 2; + T *newElems = allocate(null_terminator::allocCount(s)); // copy the elements to new storage