From 47c993dd01698793c93194327518761ad946deb8 Mon Sep 17 00:00:00 2001 From: silverweed <silverweed14@proton.me> Date: Fri, 24 Jan 2025 11:04:59 +0100 Subject: [PATCH] invert order of BgColorFn calls in mem edit to avoid cache misses BgColorFn(addr) will call find_section(addr) internally. If we call BgColorFn(addr + 1) and then BgColorFn(addr), the first call may cause the cached `last_pinfo` / `last_other_root_obj` to change to the next one in the list, which in turn will cause the second call to "page fault". Inverting the order doesn't change anything in mem_edit but it better uses our application cache to speedup section finding. --- third_party/imgui_club/imgui_memory_editor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/imgui_club/imgui_memory_editor.h b/third_party/imgui_club/imgui_memory_editor.h index 97c4b77..85924ca 100644 --- a/third_party/imgui_club/imgui_memory_editor.h +++ b/third_party/imgui_club/imgui_memory_editor.h @@ -321,8 +321,8 @@ struct MemoryEditor } else if (BgColorFn != nullptr) { - is_next_byte_highlighted = (addr + 1 < mem_size) && ((BgColorFn(mem_data, addr + 1, UserData) & IM_COL32_A_MASK) != 0); bg_color = BgColorFn(mem_data, addr, UserData); + is_next_byte_highlighted = (addr + 1 < mem_size) && ((BgColorFn(mem_data, addr + 1, UserData) & IM_COL32_A_MASK) != 0); } if (bg_color != 0) {