mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +00:00 
			
		
		
		
	Store item tree visibilities in a thin vec
This commit is contained in:
		
							parent
							
								
									17d848a1bb
								
							
						
					
					
						commit
						ace69d93e0
					
				
					 1 changed files with 14 additions and 2 deletions
				
			
		|  | @ -56,6 +56,7 @@ use rustc_hash::FxHashMap; | ||||||
| use span::{AstIdNode, Edition, FileAstId, SyntaxContext}; | use span::{AstIdNode, Edition, FileAstId, SyntaxContext}; | ||||||
| use stdx::never; | use stdx::never; | ||||||
| use syntax::{SyntaxKind, ast, match_ast}; | use syntax::{SyntaxKind, ast, match_ast}; | ||||||
|  | use thin_vec::ThinVec; | ||||||
| use triomphe::Arc; | use triomphe::Arc; | ||||||
| 
 | 
 | ||||||
| use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase}; | use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase}; | ||||||
|  | @ -144,7 +145,7 @@ pub(crate) fn block_item_tree_query(db: &dyn DefDatabase, block: BlockId) -> Arc | ||||||
|                     attrs: FxHashMap::default(), |                     attrs: FxHashMap::default(), | ||||||
|                     data: FxHashMap::default(), |                     data: FxHashMap::default(), | ||||||
|                     top_attrs: RawAttrs::EMPTY, |                     top_attrs: RawAttrs::EMPTY, | ||||||
|                     vis: ItemVisibilities { arena: Box::new([]) }, |                     vis: ItemVisibilities { arena: ThinVec::new() }, | ||||||
|                 }) |                 }) | ||||||
|             }) |             }) | ||||||
|             .clone() |             .clone() | ||||||
|  | @ -229,29 +230,40 @@ impl ItemTree { | ||||||
| 
 | 
 | ||||||
| #[derive(Default, Debug, Eq, PartialEq)] | #[derive(Default, Debug, Eq, PartialEq)] | ||||||
| struct ItemVisibilities { | struct ItemVisibilities { | ||||||
|     arena: Box<[RawVisibility]>, |     arena: ThinVec<RawVisibility>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, Clone, Eq, PartialEq)] | #[derive(Debug, Clone, Eq, PartialEq)] | ||||||
| enum ModItem { | enum ModItem { | ||||||
|     Const(Const), |     Const(Const), | ||||||
|     Enum(Enum), |     Enum(Enum), | ||||||
|  |     // 32
 | ||||||
|     ExternBlock(ExternBlock), |     ExternBlock(ExternBlock), | ||||||
|  |     // 40
 | ||||||
|     ExternCrate(ExternCrate), |     ExternCrate(ExternCrate), | ||||||
|     Function(Function), |     Function(Function), | ||||||
|     Impl(Impl), |     Impl(Impl), | ||||||
|     Macro2(Macro2), |     Macro2(Macro2), | ||||||
|  |     // 32
 | ||||||
|     MacroCall(MacroCall), |     MacroCall(MacroCall), | ||||||
|     MacroRules(MacroRules), |     MacroRules(MacroRules), | ||||||
|  |     // 40
 | ||||||
|     Mod(Mod), |     Mod(Mod), | ||||||
|     Static(Static), |     Static(Static), | ||||||
|  |     // 32
 | ||||||
|     Struct(Struct), |     Struct(Struct), | ||||||
|     Trait(Trait), |     Trait(Trait), | ||||||
|     TraitAlias(TraitAlias), |     TraitAlias(TraitAlias), | ||||||
|     TypeAlias(TypeAlias), |     TypeAlias(TypeAlias), | ||||||
|     Union(Union), |     Union(Union), | ||||||
|  |     // 40
 | ||||||
|     Use(Use), |     Use(Use), | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // `ModItem` is stored a bunch in `ItemTree`'s so we pay the max for each item. It should stay as small as possible.
 | ||||||
|  | #[cfg(target_pointer_width = "64")] | ||||||
|  | const _: [(); std::mem::size_of::<ModItem>()] = [(); std::mem::size_of::<[usize; 5]>()]; | ||||||
|  | 
 | ||||||
| #[derive(Default, Debug, Eq, PartialEq)] | #[derive(Default, Debug, Eq, PartialEq)] | ||||||
| pub struct ItemTreeDataStats { | pub struct ItemTreeDataStats { | ||||||
|     pub traits: usize, |     pub traits: usize, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth