Skip to content

Commit 5366135

Browse files
committed
Clean up YieldFinder
1 parent c711531 commit 5366135

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/middle/region.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,13 +1175,18 @@ struct YieldFinder<'a> {
11751175

11761176
impl<'a> YieldFinder<'a> {
11771177
fn lookup<F: FnOnce(&mut Self)>(&mut self, id: NodeId, f: F) {
1178-
if let Some(result) = self.cache.get(&id) {
1179-
self.result = *result;
1178+
// Don't traverse further if we found a yield expression
1179+
if self.result.is_some() {
11801180
return;
11811181
}
1182-
if self.result.is_some() {
1182+
1183+
// See if there's an entry in the cache
1184+
if let Some(result) = self.cache.get(&id) {
1185+
self.result = *result;
11831186
return;
11841187
}
1188+
1189+
// Otherwise calculate the result and insert it into the cache
11851190
f(self);
11861191
self.cache.insert(id, self.result);
11871192
}

0 commit comments

Comments
 (0)