From 39fe3bd1a749b92a2e959e73cb9342e37a9195b2 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Tue, 11 Mar 2025 21:59:05 +0100 Subject: [PATCH] Replace tail call recursion in gui.zig with a standard while loop. This brings us one tiny step closer to overlapping with the set of supported features of the x86 backend. --- src/gui/gui.zig | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gui/gui.zig b/src/gui/gui.zig index ece8fb1f..23ebf0b8 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -505,16 +505,18 @@ pub fn secondaryButtonReleased() void { } pub fn updateWindowPositions() void { - var wasChanged: bool = false; - for(windowList.items) |window| { - const oldPos = window.pos; - window.updateWindowPosition(); - const newPos = window.pos; - if(vec.lengthSquare(oldPos - newPos) >= 1e-3) { - wasChanged = true; + var wasChanged: bool = true; + while(wasChanged) { + wasChanged = false; + for(windowList.items) |window| { + const oldPos = window.pos; + window.updateWindowPosition(); + const newPos = window.pos; + if(vec.lengthSquare(oldPos - newPos) >= 1e-3) { + wasChanged = true; + } } } - if(wasChanged) @call(.always_tail, updateWindowPositions, .{}); // Very efficient O(n²) algorithm :P } pub fn updateAndRenderGui() void {