Returns an inline name directly, or a shared clone of a heap-allocated name.
(&mut self, text: &str)
| 46 | impl NameInterner { |
| 47 | /// Returns an inline name directly, or a shared clone of a heap-allocated name. |
| 48 | fn intern(&mut self, text: &str) -> Name { |
| 49 | if let Some(name) = Name::new_inline(text) { |
| 50 | return name; |
| 51 | } |
| 52 | |
| 53 | if let Some(name) = self.names.get(text) { |
| 54 | return name.clone(); |
| 55 | } |
| 56 | |
| 57 | let name = Name::new_heap(text); |
| 58 | self.names.insert(name.clone()); |
| 59 | name |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | #[derive(Debug)] |
no test coverage detected