Skip to content

Commit f7e6b18

Browse files
Intern ModPath in Import
Minor savings only
1 parent e2213a5 commit f7e6b18

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

crates/hir_def/src/item_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree {
529529
/// A desugared `use` import.
530530
#[derive(Debug, Clone, Eq, PartialEq)]
531531
pub struct Import {
532-
pub path: ModPath,
532+
pub path: Interned<ModPath>,
533533
pub alias: Option<ImportAlias>,
534534
pub visibility: RawVisibilityId,
535535
pub is_glob: bool,

crates/hir_def/src/item_tree/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl Ctx {
577577
&self.hygiene,
578578
|path, _use_tree, is_glob, alias| {
579579
imports.push(id(tree.imports.alloc(Import {
580-
path,
580+
path: Interned::new(path),
581581
alias,
582582
visibility,
583583
is_glob,

crates/hir_def/src/nameres/collector.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::{
2323
attr::Attrs,
2424
db::DefDatabase,
2525
derive_macro_as_call_id,
26+
intern::Interned,
2627
item_scope::{ImportType, PerNsGlobImports},
2728
item_tree::{
2829
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem,
@@ -139,7 +140,7 @@ enum ImportSource {
139140

140141
#[derive(Clone, Debug, Eq, PartialEq)]
141142
struct Import {
142-
path: ModPath,
143+
path: Interned<ModPath>,
143144
alias: Option<ImportAlias>,
144145
visibility: RawVisibility,
145146
is_glob: bool,
@@ -181,7 +182,10 @@ impl Import {
181182
let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into());
182183
let visibility = &tree[it.visibility];
183184
Self {
184-
path: ModPath::from_segments(PathKind::Plain, iter::once(it.name.clone())),
185+
path: Interned::new(ModPath::from_segments(
186+
PathKind::Plain,
187+
iter::once(it.name.clone()),
188+
)),
185189
alias: it.alias.clone(),
186190
visibility: visibility.clone(),
187191
is_glob: false,

0 commit comments

Comments
 (0)