From 58e08bec609d3612ef1de1baa80214b7f0a596e0 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 8 Mar 2026 03:09:39 -0400 Subject: [PATCH] Cache start node ID before main loop to avoid repeated O(n) lookup Co-Authored-By: Claude Opus 4.6 --- crates/arc-workflows/src/engine.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/arc-workflows/src/engine.rs b/crates/arc-workflows/src/engine.rs index b781467d7..8427491b1 100644 --- a/crates/arc-workflows/src/engine.rs +++ b/crates/arc-workflows/src/engine.rs @@ -1410,6 +1410,8 @@ impl WorkflowRunEngine { (token, shutdown) }); + let start_node_id = graph.find_start_node().map(|n| n.id.clone()); + loop { // Check for cancellation before processing each node if let Some(ref token) = config.cancel_token { @@ -1894,11 +1896,7 @@ impl WorkflowRunEngine { // Step 6b: Write shadow branch first, then run branch commit with trailer // Skip git checkpoint for the start node — it's a no-op, so the commit is always empty. - let is_start_node = graph - .find_start_node() - .map(|n| n.id == node.id) - .unwrap_or(false); - if !is_start_node { + if start_node_id.as_deref() != Some(&*node.id) { if let Some(ref mode) = config.git_checkpoint { // Shadow commit (best-effort): extract repo path from either variant let shadow_sha: Option = if config.meta_branch.is_some() {