inline probe_memoized_value

This commit is contained in:
Niko Matsakis 2019-07-29 18:13:51 +03:00
parent 485df37e6f
commit 4cae741768

View file

@ -340,15 +340,26 @@ where
} }
QueryState::Memoized(memo) => { QueryState::Memoized(memo) => {
debug!("{:?}: found memoized value", self); debug!(
"{:?}: found memoized value, verified_at={:?}, changed_at={:?}",
self, memo.verified_at, memo.changed_at,
);
if let Some(value) = memo.probe_memoized_value(revision_now) { if let Some(value) = &memo.value {
info!( if memo.verified_at == revision_now {
"{:?}: returning memoized value changed at {:?}", let value = StampedValue {
self, value.changed_at durability: memo.durability,
); changed_at: memo.changed_at,
value: value.clone(),
};
return ProbeState::UpToDate(Ok(value)); info!(
"{:?}: returning memoized value changed at {:?}",
self, value.changed_at
);
return ProbeState::UpToDate(Ok(value));
}
} }
} }
} }
@ -710,26 +721,6 @@ where
} }
} }
/// Returns the memoized value *if* it is known to be update in the given revision.
fn probe_memoized_value(&self, revision_now: Revision) -> Option<StampedValue<Q::Value>> {
let value = self.value.as_ref()?;
debug!(
"probe_memoized_value(verified_at={:?}, changed_at={:?})",
self.verified_at, self.changed_at,
);
if self.verified_at == revision_now {
return Some(StampedValue {
durability: self.durability,
changed_at: self.changed_at,
value: value.clone(),
});
}
None
}
fn has_untracked_input(&self) -> bool { fn has_untracked_input(&self) -> bool {
match self.inputs { match self.inputs {
MemoInputs::Untracked => true, MemoInputs::Untracked => true,