From 2bf5ca7ef2f01a30758bb2a7060d902c22b33e9e Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 4 Nov 2020 17:50:30 +0100 Subject: [PATCH] ImDrawListClipper: avoid over reserving memory. --- imgui_draw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 8ce1739f2..3dd0a360e 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1429,7 +1429,10 @@ void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count) IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter."); int old_channels_count = _Channels.Size; if (old_channels_count < channels_count) + { + _Channels.reserve(channels_count); // Avoid over reserving since this is likely to stay stable _Channels.resize(channels_count); + } _Count = channels_count; // Channels[] (24/32 bytes each) hold storage that we'll swap with draw_list->_CmdBuffer/_IdxBuffer