ImDrawListClipper: avoid over reserving memory.

This commit is contained in:
ocornut 2020-11-04 17:50:30 +01:00
parent d6a2f7e95e
commit 2bf5ca7ef2
1 changed files with 3 additions and 0 deletions

View File

@ -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