aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres/raw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres/raw.rs')
-rw-r--r--crates/ra_hir/src/nameres/raw.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs
index f02d4eb7a..623b343c4 100644
--- a/crates/ra_hir/src/nameres/raw.rs
+++ b/crates/ra_hir/src/nameres/raw.rs
@@ -120,9 +120,12 @@ impl Index<Macro> for RawItems {
120 } 120 }
121} 121}
122 122
123// Avoid heap allocation on items without attributes.
124pub(super) type Attrs = Option<Arc<[Attr]>>;
125
123#[derive(Debug, PartialEq, Eq, Clone)] 126#[derive(Debug, PartialEq, Eq, Clone)]
124pub(super) struct RawItem { 127pub(super) struct RawItem {
125 pub(super) attrs: Arc<[Attr]>, 128 pub(super) attrs: Attrs,
126 pub(super) kind: RawItemKind, 129 pub(super) kind: RawItemKind,
127} 130}
128 131
@@ -390,7 +393,7 @@ impl<DB: AstDatabase> RawItemsCollector<&DB> {
390 fn push_import( 393 fn push_import(
391 &mut self, 394 &mut self,
392 current_module: Option<Module>, 395 current_module: Option<Module>,
393 attrs: Arc<[Attr]>, 396 attrs: Attrs,
394 data: ImportData, 397 data: ImportData,
395 source: ImportSourcePtr, 398 source: ImportSourcePtr,
396 ) { 399 ) {
@@ -399,7 +402,7 @@ impl<DB: AstDatabase> RawItemsCollector<&DB> {
399 self.push_item(current_module, attrs, RawItemKind::Import(import)) 402 self.push_item(current_module, attrs, RawItemKind::Import(import))
400 } 403 }
401 404
402 fn push_item(&mut self, current_module: Option<Module>, attrs: Arc<[Attr]>, kind: RawItemKind) { 405 fn push_item(&mut self, current_module: Option<Module>, attrs: Attrs, kind: RawItemKind) {
403 match current_module { 406 match current_module {
404 Some(module) => match &mut self.raw_items.modules[module] { 407 Some(module) => match &mut self.raw_items.modules[module] {
405 ModuleData::Definition { items, .. } => items, 408 ModuleData::Definition { items, .. } => items,
@@ -410,7 +413,7 @@ impl<DB: AstDatabase> RawItemsCollector<&DB> {
410 .push(RawItem { attrs, kind }) 413 .push(RawItem { attrs, kind })
411 } 414 }
412 415
413 fn parse_attrs(&self, item: &impl ast::AttrsOwner) -> Arc<[Attr]> { 416 fn parse_attrs(&self, item: &impl ast::AttrsOwner) -> Attrs {
414 Attr::from_attrs_owner(self.file_id, item, self.db) 417 Attr::from_attrs_owner(self.file_id, item, self.db)
415 } 418 }
416} 419}