]> git.lizzy.rs Git - rust.git/commitdiff
Avoid recursion in de-gensym functions.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 9 May 2019 01:54:47 +0000 (11:54 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Fri, 10 May 2019 05:59:12 +0000 (15:59 +1000)
src/libsyntax_pos/symbol.rs

index 107cf8360c4f9534be9f768736c8ae8a93f75163..e8472e1b9f1f2b0bd51ce7cf5db1c7a418011d51 100644 (file)
@@ -492,7 +492,7 @@ pub fn interned(&self, symbol: Symbol) -> Symbol {
         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]
         }
     }
 
@@ -513,7 +513,10 @@ fn is_gensymed(&mut self, symbol: Symbol) -> bool {
     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()]
+            }
         }
     }
 }