From 3144cda7fcb30beaa78e85783d0af8994484edfe Mon Sep 17 00:00:00 2001 From: Eugene Blikh Date: Tue, 28 Apr 2026 03:54:11 +0300 Subject: [PATCH] systems-power: hoist HUD cellBottom out of inner loop Reviewer flagged the per-iteration recomputation of cellBottom inside drawHud's column/cell loops; the value was loop-invariant. Hoist to a file-scope const and simplify the algebra. systems-power --- render.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/render.go b/render.go index 9bfa2d65398a94599213b77bd9bd95cf227b63b4..dfdf3aa2edc10b749951ea59e5318bb091176823 100644 --- a/render.go +++ b/render.go @@ -97,6 +97,8 @@ func drawHud(screen *ebiten.Image, sys []System) { const cellW = 12 const cellH = 10 const cellGap = 2 + // cellBottom is the y of the bottom-most cell's top edge; loop-invariant. + const cellBottom = VirtualH - cellGap outline := color.RGBA{255, 255, 255, 255} // Role labels in display order (index == int(RoomRole)). @@ -112,9 +114,6 @@ func drawHud(screen *ebiten.Image, sys []System) { // Cells stacked bottom-up. Row 0 is at the bottom of the HUD strip. for j := 0; j < s.MaxLevel; j++ { - // Compute y so that row 0 is at the bottom. We allocate space - // starting below the label (label height ~12px). - cellBottom := HudY + (VirtualH - HudY) - cellGap cy := cellBottom - (j+1)*(cellH+cellGap) cx := colLeft + 4