diff --git a/src/function/accumulated.rs b/src/function/accumulated.rs index 2bfcbf9d..51b16fa3 100644 --- a/src/function/accumulated.rs +++ b/src/function/accumulated.rs @@ -1,5 +1,3 @@ -use std::collections::VecDeque; - use crate::{accumulator, hash::FxHashSet, storage::DatabaseGen, DatabaseKeyIndex, Id}; use super::{Configuration, IngredientImpl}; @@ -25,10 +23,9 @@ where let db_key = self.database_key_index(key); let mut visited: FxHashSet = std::iter::once(db_key).collect(); - let mut stack = VecDeque::new(); - stack.push_front(db_key); + let mut stack = vec![db_key]; - while let Some(k) = stack.pop_front() { + while let Some(k) = stack.pop() { accumulator.produced_by(runtime, k, &mut output); let origin = db.lookup_ingredient(k.ingredient_index).origin(k.key_index); @@ -37,7 +34,7 @@ where for input in inputs { if let Ok(input) = input.try_into() { if visited.insert(input) { - stack.push_back(input); + stack.push(input); } } } diff --git a/tests/accumulate-dag.rs b/tests/accumulate-dag.rs index d0c0cfeb..d7decab7 100644 --- a/tests/accumulate-dag.rs +++ b/tests/accumulate-dag.rs @@ -45,12 +45,6 @@ fn accumulate_a_called_twice() { // Check that we don't see logs from `a` appearing twice in the input. expect![[r#" [ - Log( - "log_a(0 of 2)", - ), - Log( - "log_a(1 of 2)", - ), Log( "log_b(0 of 3)", ), @@ -60,6 +54,12 @@ fn accumulate_a_called_twice() { Log( "log_b(2 of 3)", ), + Log( + "log_a(0 of 2)", + ), + Log( + "log_a(1 of 2)", + ), ]"#]] .assert_eq(&format!("{:#?}", logs)); }) diff --git a/tests/accumulate.rs b/tests/accumulate.rs index 3b6ce192..0387bac3 100644 --- a/tests/accumulate.rs +++ b/tests/accumulate.rs @@ -94,12 +94,6 @@ fn accumulate_once() { // (execution order). expect![[r#" [ - Log( - "log_a(0 of 2)", - ), - Log( - "log_a(1 of 2)", - ), Log( "log_b(0 of 3)", ), @@ -109,6 +103,12 @@ fn accumulate_once() { Log( "log_b(2 of 3)", ), + Log( + "log_a(0 of 2)", + ), + Log( + "log_a(1 of 2)", + ), ]"#]] .assert_eq(&format!("{:#?}", logs)); } @@ -122,12 +122,6 @@ fn change_a_from_2_to_0() { let logs = push_logs::accumulated::(&db, input); expect![[r#" [ - Log( - "log_a(0 of 2)", - ), - Log( - "log_a(1 of 2)", - ), Log( "log_b(0 of 3)", ), @@ -137,6 +131,12 @@ fn change_a_from_2_to_0() { Log( "log_b(2 of 3)", ), + Log( + "log_a(0 of 2)", + ), + Log( + "log_a(1 of 2)", + ), ]"#]] .assert_eq(&format!("{:#?}", logs)); db.assert_logs(expect![[r#" @@ -177,12 +177,6 @@ fn change_a_from_2_to_1() { let logs = push_logs::accumulated::(&db, input); expect![[r#" [ - Log( - "log_a(0 of 2)", - ), - Log( - "log_a(1 of 2)", - ), Log( "log_b(0 of 3)", ), @@ -192,6 +186,12 @@ fn change_a_from_2_to_1() { Log( "log_b(2 of 3)", ), + Log( + "log_a(0 of 2)", + ), + Log( + "log_a(1 of 2)", + ), ]"#]] .assert_eq(&format!("{:#?}", logs)); db.assert_logs(expect![[r#" @@ -206,9 +206,6 @@ fn change_a_from_2_to_1() { let logs = push_logs::accumulated::(&db, input); expect![[r#" [ - Log( - "log_a(0 of 1)", - ), Log( "log_b(0 of 3)", ), @@ -218,6 +215,9 @@ fn change_a_from_2_to_1() { Log( "log_b(2 of 3)", ), + Log( + "log_a(0 of 1)", + ), ]"#]] .assert_eq(&format!("{:#?}", logs)); db.assert_logs(expect![[r#"