diff options
| author | DaniPopes <57450786+DaniPopes@users.noreply.github.com> | 2025-04-26 22:06:42 +0200 |
|---|---|---|
| committer | DaniPopes <57450786+DaniPopes@users.noreply.github.com> | 2025-04-26 22:06:44 +0200 |
| commit | 6f5698c3683f0b158399c0c22c88234dfb695c29 (patch) | |
| tree | 41dd6b28c649bcabb61d9636e764ae241f8307ec | |
| parent | 10fa3c449f6b1613b352a6cbf78d3d91fd9a1d81 (diff) | |
| download | rust-6f5698c3683f0b158399c0c22c88234dfb695c29.tar.gz rust-6f5698c3683f0b158399c0c22c88234dfb695c29.zip | |
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.
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 3660bb3f780..5679d4566dc 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -812,7 +812,10 @@ impl<'tcx> LateContext<'tcx> { return Ok(()); } - self.path.push(Symbol::intern(&disambiguated_data.data.to_string())); + self.path.push(match disambiguated_data.data.get_opt_name() { + Some(sym) => sym, + None => Symbol::intern(&disambiguated_data.data.to_string()), + }); Ok(()) } |
