mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
Deduplicate ingredient indexing
This commit is contained in:
parent
3c7f1694c9
commit
669cbd8a10
3 changed files with 5 additions and 16 deletions
|
@ -61,7 +61,7 @@ pub struct IngredientImpl<A: Accumulator> {
|
|||
}
|
||||
|
||||
impl<A: Accumulator> IngredientImpl<A> {
|
||||
/// Find the accumulator ingrediate for `A` in the database, if any.
|
||||
/// Find the accumulator ingredient for `A` in the database, if any.
|
||||
pub fn from_db<Db>(db: &Db) -> Option<&Self>
|
||||
where
|
||||
Db: ?Sized + Database,
|
||||
|
|
|
@ -53,8 +53,9 @@ where
|
|||
continue;
|
||||
}
|
||||
|
||||
let ingredient = zalsa.lookup_ingredient(k.ingredient_index);
|
||||
// Extend `output` with any values accumulated by `k`.
|
||||
if let Some(accumulated_map) = k.accumulated(db) {
|
||||
if let Some(accumulated_map) = ingredient.accumulated(db, k.key_index) {
|
||||
accumulated_map.extend_with_accumulated(accumulator.index(), &mut output);
|
||||
|
||||
// Skip over the inputs because we know that the entire sub-graph has no accumulated values
|
||||
|
@ -69,10 +70,7 @@ where
|
|||
// output vector, we want to push in execution order, so reverse order to
|
||||
// ensure the first child that was executed will be the first child popped
|
||||
// from the stack.
|
||||
let Some(origin) = zalsa
|
||||
.lookup_ingredient(k.ingredient_index)
|
||||
.origin(db, k.key_index)
|
||||
else {
|
||||
let Some(origin) = ingredient.origin(db, k.key_index) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
11
src/key.rs
11
src/key.rs
|
@ -1,7 +1,4 @@
|
|||
use crate::{
|
||||
accumulator::accumulated_map::AccumulatedMap, cycle::CycleRecoveryStrategy,
|
||||
zalsa::IngredientIndex, Database, Id,
|
||||
};
|
||||
use crate::{cycle::CycleRecoveryStrategy, zalsa::IngredientIndex, Database, Id};
|
||||
|
||||
/// An integer that uniquely identifies a particular query instance within the
|
||||
/// database. Used to track dependencies between queries. Fully ordered and
|
||||
|
@ -99,12 +96,6 @@ impl DatabaseKeyIndex {
|
|||
pub(crate) fn cycle_recovery_strategy(self, db: &dyn Database) -> CycleRecoveryStrategy {
|
||||
self.ingredient_index.cycle_recovery_strategy(db)
|
||||
}
|
||||
|
||||
pub(crate) fn accumulated(self, db: &dyn Database) -> Option<&AccumulatedMap> {
|
||||
db.zalsa()
|
||||
.lookup_ingredient(self.ingredient_index)
|
||||
.accumulated(db, self.key_index)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for DatabaseKeyIndex {
|
||||
|
|
Loading…
Reference in a new issue