From 7d230594decfb434624c3d466acc95f96132ed5e Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 16:25:33 +0200 Subject: [PATCH] Fixed ImHashSkipUncontributingPrefix() not looping in case of multiple ### elements. --- imgui.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4207012ed..57ea52195 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2388,11 +2388,14 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed) } // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() +// FIXME-OPT: This is not designed to be optimal. Use with care. const char* ImHashSkipUncontributingPrefix(const char* label) { - if (const char* p = strstr(label, "###")) // FIXME: Should loop. - label = p; - return label; + const char* result = label; + while (unsigned char c = *label++) + if (c == '#' && label[0] == '#' && label[1] == '#') + result = label - 1; + return result; } //-----------------------------------------------------------------------------