This commit is contained in:
Phoebe Szmucer 2024-07-21 18:20:26 +01:00
parent beedbd18e5
commit a20c6341ec
3 changed files with 30 additions and 33 deletions

View file

@ -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<DatabaseKeyIndex> = 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);
}
}
}

View file

@ -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));
})

View file

@ -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::<Log>(&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::<Log>(&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::<Log>(&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#"