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.
This commit is contained in:
silverweed 2025-01-24 11:04:59 +01:00
parent aef07b24f9
commit 47c993dd01

View file

@ -321,8 +321,8 @@ struct MemoryEditor
} }
else if (BgColorFn != nullptr) 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); 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) if (bg_color != 0)
{ {