This commit is contained in:
Ian 2026-08-03 15:32:25 -04:00
parent a2a1f89926
commit ec3584e7c2
2 changed files with 18 additions and 3 deletions

View file

@ -228,15 +228,29 @@ local function remove_dependency_counts(node) -- to be called when updating a no
for i = 1, #node do for i = 1, #node do
local child = node[i] local child = node[i]
if not node.owner then continue end -- we won't be updating this anyway if not node.owner then continue end -- we won't be updating this anyway
node_deps_left[child] -= 1 local deps_left = node_deps_left[child]
if deps_left > 1 then
node_deps_left[child] = deps_left - 1
else
node_deps_left[child] = 0
-- only recurse if we're removing the last dependency *and* if we aren't planning on updating it
if not in_queue[child] then
remove_dependency_counts(child) remove_dependency_counts(child)
end end
end
end
end end
local function queue_children_for_update<T>(node: SourceNode<T>) local function queue_children_for_update<T>(node: SourceNode<T>)
for i = 1, #node do for i = 1, #node do
local child = node[i] local child = node[i]
node_deps_left[child] -= 1 local deps_left = node_deps_left[child]
if deps_left then
node_deps_left[child] = deps_left - 1
else
-- This can happen if child adds parent as a new dependency after the initial update
node_deps_left[child] = 0
end
if not in_queue[child] then if not in_queue[child] then
in_queue[child] = true in_queue[child] = true
update_queue_n += 1 update_queue_n += 1

View file

@ -1,3 +1,4 @@
# todo # todo
- improve error traces - improve error traces
- prevent redundant re-eval of nodes in complex graphs after a node adds a dependency mid-update