Skip to content

Commit 5633102

Browse files
authored
Rollup merge of #140345 - DaniPopes:get-def-path, r=Urgau
Avoid re-interning in `LateContext::get_def_path` The def path printer in `get_def_path` essentially calls `Symbol::intern(&symbol.to_string())` for simple symbols in a path. This accounts for ~30% of the runtime of get_def_path. We can avoid this by simply appending the symbol directly when available.
2 parents c439543 + 6f5698c commit 5633102

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_lint/src/context.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,10 @@ impl<'tcx> LateContext<'tcx> {
812812
return Ok(());
813813
}
814814

815-
self.path.push(Symbol::intern(&disambiguated_data.data.to_string()));
815+
self.path.push(match disambiguated_data.data.get_opt_name() {
816+
Some(sym) => sym,
817+
None => Symbol::intern(&disambiguated_data.data.to_string()),
818+
});
816819
Ok(())
817820
}
818821

0 commit comments

Comments
 (0)