mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Intern ModPath
in Import
Minor savings only
This commit is contained in:
parent
e2213a503e
commit
f7e6b186e1
3 changed files with 8 additions and 4 deletions
|
@ -529,7 +529,7 @@ impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree {
|
||||||
/// A desugared `use` import.
|
/// A desugared `use` import.
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Import {
|
pub struct Import {
|
||||||
pub path: ModPath,
|
pub path: Interned<ModPath>,
|
||||||
pub alias: Option<ImportAlias>,
|
pub alias: Option<ImportAlias>,
|
||||||
pub visibility: RawVisibilityId,
|
pub visibility: RawVisibilityId,
|
||||||
pub is_glob: bool,
|
pub is_glob: bool,
|
||||||
|
|
|
@ -577,7 +577,7 @@ impl Ctx {
|
||||||
&self.hygiene,
|
&self.hygiene,
|
||||||
|path, _use_tree, is_glob, alias| {
|
|path, _use_tree, is_glob, alias| {
|
||||||
imports.push(id(tree.imports.alloc(Import {
|
imports.push(id(tree.imports.alloc(Import {
|
||||||
path,
|
path: Interned::new(path),
|
||||||
alias,
|
alias,
|
||||||
visibility,
|
visibility,
|
||||||
is_glob,
|
is_glob,
|
||||||
|
|
|
@ -23,6 +23,7 @@ use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
derive_macro_as_call_id,
|
derive_macro_as_call_id,
|
||||||
|
intern::Interned,
|
||||||
item_scope::{ImportType, PerNsGlobImports},
|
item_scope::{ImportType, PerNsGlobImports},
|
||||||
item_tree::{
|
item_tree::{
|
||||||
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem,
|
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem,
|
||||||
|
@ -139,7 +140,7 @@ enum ImportSource {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
struct Import {
|
struct Import {
|
||||||
path: ModPath,
|
path: Interned<ModPath>,
|
||||||
alias: Option<ImportAlias>,
|
alias: Option<ImportAlias>,
|
||||||
visibility: RawVisibility,
|
visibility: RawVisibility,
|
||||||
is_glob: bool,
|
is_glob: bool,
|
||||||
|
@ -181,7 +182,10 @@ impl Import {
|
||||||
let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into());
|
let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into());
|
||||||
let visibility = &tree[it.visibility];
|
let visibility = &tree[it.visibility];
|
||||||
Self {
|
Self {
|
||||||
path: ModPath::from_segments(PathKind::Plain, iter::once(it.name.clone())),
|
path: Interned::new(ModPath::from_segments(
|
||||||
|
PathKind::Plain,
|
||||||
|
iter::once(it.name.clone()),
|
||||||
|
)),
|
||||||
alias: it.alias.clone(),
|
alias: it.alias.clone(),
|
||||||
visibility: visibility.clone(),
|
visibility: visibility.clone(),
|
||||||
is_glob: false,
|
is_glob: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue