aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-26 00:26:16 +0100
committerJonas Schievink <[email protected]>2021-05-26 00:26:16 +0100
commitfe910c7bc4aac8a33fc1933d64aa260d42a3c4f1 (patch)
treea5df80090790ee5c67cb54fa8a470859c008bd01 /crates/hir_def
parent356dd3d909f20b5b1e1c44205d522b7b2ead0d0e (diff)
Reduce memory usage a bit
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/item_tree.rs8
-rw-r--r--crates/hir_def/src/item_tree/lower.rs15
2 files changed, 14 insertions, 9 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index 508736885..c960f66d6 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -543,18 +543,18 @@ pub enum UseTreeKind {
543 /// use path::to::Item as Renamed; 543 /// use path::to::Item as Renamed;
544 /// use path::to::Trait as _; 544 /// use path::to::Trait as _;
545 /// ``` 545 /// ```
546 Single { path: ModPath, alias: Option<ImportAlias> }, 546 Single { path: Interned<ModPath>, alias: Option<ImportAlias> },
547 547
548 /// ```ignore 548 /// ```ignore
549 /// use *; // (invalid, but can occur in nested tree) 549 /// use *; // (invalid, but can occur in nested tree)
550 /// use path::*; 550 /// use path::*;
551 /// ``` 551 /// ```
552 Glob { path: Option<ModPath> }, 552 Glob { path: Option<Interned<ModPath>> },
553 553
554 /// ```ignore 554 /// ```ignore
555 /// use prefix::{self, Item, ...}; 555 /// use prefix::{self, Item, ...};
556 /// ``` 556 /// ```
557 Prefixed { prefix: Option<ModPath>, list: Vec<UseTree> }, 557 Prefixed { prefix: Option<Interned<ModPath>>, list: Box<[UseTree]> },
558} 558}
559 559
560#[derive(Debug, Clone, Eq, PartialEq)] 560#[derive(Debug, Clone, Eq, PartialEq)]
@@ -811,7 +811,7 @@ impl UseTree {
811 }, 811 },
812 None => prefix, 812 None => prefix,
813 }; 813 };
814 for tree in list { 814 for tree in &**list {
815 tree.expand_impl(prefix.clone(), cb); 815 tree.expand_impl(prefix.clone(), cb);
816 } 816 }
817 } 817 }
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 798ab46dd..40f3428b7 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -864,7 +864,12 @@ impl UseTreeLowering<'_> {
864 let list = 864 let list =
865 use_tree_list.use_trees().filter_map(|tree| self.lower_use_tree(tree)).collect(); 865 use_tree_list.use_trees().filter_map(|tree| self.lower_use_tree(tree)).collect();
866 866
867 Some(self.use_tree(UseTreeKind::Prefixed { prefix, list }, tree)) 867 Some(
868 self.use_tree(
869 UseTreeKind::Prefixed { prefix: prefix.map(Interned::new), list },
870 tree,
871 ),
872 )
868 } else { 873 } else {
869 let is_glob = tree.star_token().is_some(); 874 let is_glob = tree.star_token().is_some();
870 let path = match tree.path() { 875 let path = match tree.path() {
@@ -883,15 +888,15 @@ impl UseTreeLowering<'_> {
883 if path.is_none() { 888 if path.is_none() {
884 cov_mark::hit!(glob_enum_group); 889 cov_mark::hit!(glob_enum_group);
885 } 890 }
886 Some(self.use_tree(UseTreeKind::Glob { path }, tree)) 891 Some(self.use_tree(UseTreeKind::Glob { path: path.map(Interned::new) }, tree))
887 } 892 }
888 // Globs can't be renamed 893 // Globs can't be renamed
889 (_, Some(_), true) | (None, None, false) => None, 894 (_, Some(_), true) | (None, None, false) => None,
890 // `bla::{ as Name}` is invalid 895 // `bla::{ as Name}` is invalid
891 (None, Some(_), false) => None, 896 (None, Some(_), false) => None,
892 (Some(path), alias, false) => { 897 (Some(path), alias, false) => Some(
893 Some(self.use_tree(UseTreeKind::Single { path, alias }, tree)) 898 self.use_tree(UseTreeKind::Single { path: Interned::new(path), alias }, tree),
894 } 899 ),
895 } 900 }
896 } 901 }
897 } 902 }