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 <noreply@anthropic.com>
This commit is contained in:
parent
292d45e179
commit
6ada00ad99
1 changed files with 18 additions and 1 deletions
19
ui/main.gd
19
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue