impl<'a> YieldFinder<'a> {
fn lookup<F: FnOnce(&mut Self)>(&mut self, id: NodeId, f: F) {
- if let Some(result) = self.cache.get(&id) {
- self.result = *result;
+ // Don't traverse further if we found a yield expression
+ if self.result.is_some() {
return;
}
- if self.result.is_some() {
+
+ // See if there's an entry in the cache
+ if let Some(result) = self.cache.get(&id) {
+ self.result = *result;
return;
}
+
+ // Otherwise calculate the result and insert it into the cache
f(self);
self.cache.insert(id, self.result);
}