Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6dd7641

Browse files
authored
Rollup merge of rust-lang#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 19f984d + 6f5698c commit 6dd7641

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_lint/src/context.rs

Lines changed: 4 additions & 1 deletion
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)