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 {
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 {