@@ -56,6 +56,7 @@ use rustc_hash::FxHashMap;
56
56
use span:: { AstIdNode , Edition , FileAstId , SyntaxContext } ;
57
57
use stdx:: never;
58
58
use syntax:: { SyntaxKind , ast, match_ast} ;
59
+ use thin_vec:: ThinVec ;
59
60
use triomphe:: Arc ;
60
61
61
62
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
144
145
attrs : FxHashMap :: default ( ) ,
145
146
data : FxHashMap :: default ( ) ,
146
147
top_attrs : RawAttrs :: EMPTY ,
147
- vis : ItemVisibilities { arena : Box :: new ( [ ] ) } ,
148
+ vis : ItemVisibilities { arena : ThinVec :: new ( ) } ,
148
149
} )
149
150
} )
150
151
. clone ( )
@@ -229,29 +230,40 @@ impl ItemTree {
229
230
230
231
#[ derive( Default , Debug , Eq , PartialEq ) ]
231
232
struct ItemVisibilities {
232
- arena : Box < [ RawVisibility ] > ,
233
+ arena : ThinVec < RawVisibility > ,
233
234
}
234
235
235
236
#[ derive( Debug , Clone , Eq , PartialEq ) ]
236
237
enum ModItem {
237
238
Const ( Const ) ,
238
239
Enum ( Enum ) ,
240
+ // 32
239
241
ExternBlock ( ExternBlock ) ,
242
+ // 40
240
243
ExternCrate ( ExternCrate ) ,
241
244
Function ( Function ) ,
242
245
Impl ( Impl ) ,
243
246
Macro2 ( Macro2 ) ,
247
+ // 32
244
248
MacroCall ( MacroCall ) ,
245
249
MacroRules ( MacroRules ) ,
250
+ // 40
246
251
Mod ( Mod ) ,
247
252
Static ( Static ) ,
253
+ // 32
248
254
Struct ( Struct ) ,
249
255
Trait ( Trait ) ,
250
256
TraitAlias ( TraitAlias ) ,
251
257
TypeAlias ( TypeAlias ) ,
252
258
Union ( Union ) ,
259
+ // 40
253
260
Use ( Use ) ,
254
261
}
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
+
255
267
#[ derive( Default , Debug , Eq , PartialEq ) ]
256
268
pub struct ItemTreeDataStats {
257
269
pub traits : usize ,
0 commit comments