MCPcopy Create free account
hub / github.com/astral-sh/ruff / intern

Method intern

crates/ruff_python_parser/src/parser/mod.rs:48–60  ·  view source on GitHub ↗

Returns an inline name directly, or a shared clone of a heap-allocated name.

(&mut self, text: &str)

Source from the content-addressed store, hash-verified

46impl 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)]

Callers 3

intern_nameMethod · 0.45
parse_dotted_nameMethod · 0.45

Calls 3

getMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected