@@ -56,6 +56,7 @@ use rustc_hash::FxHashMap;
5656use span:: { AstIdNode , Edition , FileAstId , SyntaxContext } ;
5757use stdx:: never;
5858use syntax:: { SyntaxKind , ast, match_ast} ;
59+ use thin_vec:: ThinVec ;
5960use triomphe:: Arc ;
6061
6162use crate :: { BlockId , Lookup , attr:: Attrs , db:: DefDatabase } ;
@@ -144,7 +145,7 @@ pub(crate) fn block_item_tree_query(db: &dyn DefDatabase, block: BlockId) -> Arc
144145 attrs : FxHashMap :: default ( ) ,
145146 data : FxHashMap :: default ( ) ,
146147 top_attrs : RawAttrs :: EMPTY ,
147- vis : ItemVisibilities { arena : Box :: new ( [ ] ) } ,
148+ vis : ItemVisibilities { arena : ThinVec :: new ( ) } ,
148149 } )
149150 } )
150151 . clone ( )
@@ -229,29 +230,40 @@ impl ItemTree {
229230
230231#[ derive( Default , Debug , Eq , PartialEq ) ]
231232struct ItemVisibilities {
232- arena : Box < [ RawVisibility ] > ,
233+ arena : ThinVec < RawVisibility > ,
233234}
234235
235236#[ derive( Debug , Clone , Eq , PartialEq ) ]
236237enum ModItem {
237238 Const ( Const ) ,
238239 Enum ( Enum ) ,
240+ // 32
239241 ExternBlock ( ExternBlock ) ,
242+ // 40
240243 ExternCrate ( ExternCrate ) ,
241244 Function ( Function ) ,
242245 Impl ( Impl ) ,
243246 Macro2 ( Macro2 ) ,
247+ // 32
244248 MacroCall ( MacroCall ) ,
245249 MacroRules ( MacroRules ) ,
250+ // 40
246251 Mod ( Mod ) ,
247252 Static ( Static ) ,
253+ // 32
248254 Struct ( Struct ) ,
249255 Trait ( Trait ) ,
250256 TraitAlias ( TraitAlias ) ,
251257 TypeAlias ( TypeAlias ) ,
252258 Union ( Union ) ,
259+ // 40
253260 Use ( Use ) ,
254261}
262+
263+ // `ModItem` is stored a bunch in `ItemTree`'s so we pay the max for each item. It should stay as small as possible.
264+ #[ cfg( target_pointer_width = "64" ) ]
265+ const _: [ ( ) ; std:: mem:: size_of :: < ModItem > ( ) ] = [ ( ) ; std:: mem:: size_of :: < [ usize ; 5 ] > ( ) ] ;
266+
255267#[ derive( Default , Debug , Eq , PartialEq ) ]
256268pub struct ItemTreeDataStats {
257269 pub traits : usize ,
0 commit comments