From 749e8fa345eb53ede6041c4e6ba946296c659f5e Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 31 Dec 2015 12:11:28 +0100 Subject: [PATCH] Minor optimization so that mass-calling BeginPopupContext* functions can early out more commonly without hashing ID --- imgui.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index bfa2a49c..83588ec3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3208,7 +3208,8 @@ void ImGui::CloseCurrentPopup() static inline void ClearSetNextWindowData() { ImGuiState& g = *GImGui; - g.SetNextWindowPosCond = g.SetNextWindowSizeCond = g.SetNextWindowContentSizeCond = g.SetNextWindowCollapsedCond = g.SetNextWindowFocus = 0; + g.SetNextWindowPosCond = g.SetNextWindowSizeCond = g.SetNextWindowContentSizeCond = g.SetNextWindowCollapsedCond = 0; + g.SetNextWindowFocus = false; } static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags) @@ -3243,6 +3244,11 @@ static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags) bool ImGui::BeginPopup(const char* str_id) { + if (GImGui->OpenedPopupStack.Size <= GImGui->CurrentPopupStack.Size) // Early out for performance + { + ClearSetNextWindowData(); // We behave like Begin() and need to consume those values + return false; + } return BeginPopupEx(str_id, ImGuiWindowFlags_ShowBorders); }