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.
This commit is contained in:
IntegratedQuantum 2025-03-11 21:59:05 +01:00
parent 4bdf1240b8
commit 39fe3bd1a7

View File

@ -505,16 +505,18 @@ pub fn secondaryButtonReleased() void {
} }
pub fn updateWindowPositions() void { pub fn updateWindowPositions() void {
var wasChanged: bool = false; var wasChanged: bool = true;
for(windowList.items) |window| { while(wasChanged) {
const oldPos = window.pos; wasChanged = false;
window.updateWindowPosition(); for(windowList.items) |window| {
const newPos = window.pos; const oldPos = window.pos;
if(vec.lengthSquare(oldPos - newPos) >= 1e-3) { window.updateWindowPosition();
wasChanged = true; 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 { pub fn updateAndRenderGui() void {