From 6ada00ad99981775e0e5ea2747eb63546f7748d5 Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Sun, 8 Nov 2026 19:03:39 -0600 Subject: [PATCH] Run the endless-loop check after edits pause, not on every change Roller.endless_cycles walks the whole board (about 30 ms on an 800-card board) and ran on every keystroke in Build mode. It now runs 0.4 s after edits stop, so a change costs about 0.4 ms instead of 34 ms. Co-Authored-By: Claude Opus 5.5 --- ui/main.gd | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/main.gd b/ui/main.gd index 91fa526..e4aa2bf 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -427,7 +427,7 @@ func _board_changed() -> void: view_rev += 1 edit_rev += 1 _update_collapse_all() - _update_endless_chip() + _schedule_endless_check() if mode == Mode.BUILD: refresh_live() @@ -3347,3 +3347,20 @@ func _run_undo_cli(args: PackedStringArray) -> void: ev.global_position = ev.position get_viewport().push_input(ev) await get_tree().process_frame + + +# ---------- Endless-loop check, debounced ---------- + +var _endless_timer: Timer + +## The endless-loop check walks the whole board (about 30 ms on an 800-card +## board), so edits schedule it to run once typing pauses instead of on every +## keystroke. +func _schedule_endless_check() -> void: + if _endless_timer == null: + _endless_timer = Timer.new() + _endless_timer.one_shot = true + _endless_timer.wait_time = 0.4 + _endless_timer.timeout.connect(_update_endless_chip) + add_child(_endless_timer) + _endless_timer.start()