File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,20 +87,20 @@ pub trait GcInternedSliceVisit: SliceInternable {
8787#[ derive( Default ) ]
8888pub struct GarbageCollector {
8989 alive : FxHashSet < usize > ,
90- storages : Vec < Box < dyn Storage + Send + Sync > > ,
90+ storages : Vec < & ' static ( dyn Storage + Send + Sync ) > ,
9191}
9292
9393impl GarbageCollector {
9494 pub fn add_storage < T : Internable + GcInternedVisit > ( & mut self ) {
9595 const { assert ! ( T :: USE_GC ) } ;
9696
97- self . storages . push ( Box :: new ( InternedStorage :: < T > ( PhantomData ) ) ) ;
97+ self . storages . push ( & InternedStorage :: < T > ( PhantomData ) ) ;
9898 }
9999
100100 pub fn add_slice_storage < T : SliceInternable + GcInternedSliceVisit > ( & mut self ) {
101101 const { assert ! ( T :: USE_GC ) } ;
102102
103- self . storages . push ( Box :: new ( InternedSliceStorage :: < T > ( PhantomData ) ) ) ;
103+ self . storages . push ( & InternedSliceStorage :: < T > ( PhantomData ) ) ;
104104 }
105105
106106 /// # Safety
@@ -111,11 +111,12 @@ impl GarbageCollector {
111111 /// - [`GcInternedVisit`] and [`GcInternedSliceVisit`] must mark all values reachable from the node.
112112 pub unsafe fn collect ( mut self ) {
113113 let total_nodes = self . storages . iter ( ) . map ( |storage| storage. len ( ) ) . sum ( ) ;
114- self . alive = FxHashSet :: with_capacity_and_hasher ( total_nodes, FxBuildHasher ) ;
114+ self . alive . clear ( ) ;
115+ self . alive . reserve ( total_nodes) ;
115116
116117 let storages = std:: mem:: take ( & mut self . storages ) ;
117118
118- for storage in & storages {
119+ for & storage in & storages {
119120 storage. mark ( & mut self ) ;
120121 }
121122
You can’t perform that action at this time.
0 commit comments