Library: fewer calls/lookups per text item, table cell and frame

- Text(): TextV() inlined (one vararg call less per formatted Text); TextEx(): CalcTextSize() inlined
- ImFontCalcTextSizeXY / RenderText / CalcWordWrapPosition: GetFontBaked() fast path inlined (LastBaked check)
- TableBeginCell(): SetWindowClipRectBeforeSetChannel() inlined; SetCurrentChannel(): skip the TexRef field reads
  when both commands share the same TexRef (as ImDrawCmd_HeaderCompare already does)
- UpdateKeyboardInputs / UpdateKeyRoutingTable: loop-invariant field reads hoisted
- `#` on strings replaced by string.len() in ImFontCalcTextSizeXY (`#` is not a native fast path)

Headless --roblox: stress+demo 0.98 -> 0.89 ms/frame, empty frame 0.085 -> 0.067 ms; draw data unchanged.
This commit is contained in:
4DBug committed 2026-10-20 15:19:28 -05:00
1 parent d9d8ee4e6b
commit ca571ee788
4 files changed
+55 -20

No files matched your search

+15 -1
View File
@@ -2613,7 +2613,21 @@ function ImGui.TableBeginCell(table_, column_n)
--IM_ASSERT(table.DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP)
else
-- FIXME-TABLE: Could avoid this if draw channel is dummy channel?
ImGui.SetWindowClipRectBeforeSetChannel(window, column.ClipRect)
-- [Luau] inline ImGui.SetWindowClipRectBeforeSetChannel(window, column.ClipRect)
local cr = column.ClipRect
local x1, y1, x2, y2 = cr.Min.x, cr.Min.y, cr.Max.x, cr.Max.y
local wcr = window.ClipRect
wcr.Min.x = x1; wcr.Min.y = y1; wcr.Max.x = x2; wcr.Max.y = y2
local draw_list = window.DrawList
local hcr = draw_list._CmdHeader.ClipRect
hcr.x = x1; hcr.y = y1; hcr.z = x2; hcr.w = y2
local stack = draw_list._ClipRectStack
local top = stack.Data[stack.Size]
if top ~= nil then
top.x = x1; top.y = y1; top.z = x2; top.w = y2
else
stack.Data[stack.Size] = ImVec4(x1, y1, x2, y2)
end
local channel = column.DrawChannelCurrent
if splitter._Current ~= channel then
splitter:SetCurrentChannel(window.DrawList, channel)