Skip to content

Commit

Permalink
Avoid recursion in de-gensym functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed May 10, 2019
1 parent 8c465b4 commit c2cae7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -492,7 +492,7 @@ impl Interner {
if (symbol.0.as_usize()) < self.strings.len() {
symbol
} else {
self.interned(self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize])
self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize]
}
}

Expand All @@ -513,7 +513,10 @@ impl Interner {
pub fn get(&self, symbol: Symbol) -> &str {
match self.strings.get(symbol.0.as_usize()) {
Some(string) => string,
None => self.get(self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize]),
None => {
let symbol = self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize];
self.strings[symbol.0.as_usize()]
}
}
}
}
Expand Down

0 comments on commit c2cae7b

Please sign in to comment.