@@ -876,16 +876,16 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T,
876876 }
877877 }
878878
879- /// fill in `possible_evictions` from `iter` by checking age
879+ /// Collect possible evictions from `iter` by checking age
880880 /// Filter as much as possible and capture dirty flag
881881 /// Skip entries with ref_count != 1 since they will be rejected later anyway
882882 fn gather_possible_evictions < ' a > (
883883 iter : impl Iterator < Item = ( & ' a Pubkey , & ' a Box < AccountMapEntry < T > > ) > ,
884- possible_evictions : & mut Vec < ( Pubkey , /*is_dirty*/ bool ) > ,
885884 startup : bool ,
886885 current_age : Age ,
887886 ages_flushing_now : Age ,
888- ) {
887+ ) -> Vec < ( Pubkey , /*is_dirty*/ bool ) > {
888+ let mut possible_evictions = Vec :: new ( ) ;
889889 for ( k, v) in iter {
890890 if !startup && current_age. wrapping_sub ( v. age ( ) ) > ages_flushing_now {
891891 // not planning to evict this item from memory within 'ages_flushing_now' ages
@@ -901,6 +901,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T,
901901
902902 possible_evictions. push ( ( * k, v. dirty ( ) ) ) ;
903903 }
904+ possible_evictions
904905 }
905906
906907 /// scan loop
@@ -915,19 +916,17 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T,
915916 _flush_guard : & FlushGuard ,
916917 ages_flushing_now : Age ,
917918 ) -> Vec < ( Pubkey , /*is_dirty*/ bool ) > {
918- let mut possible_evictions = Vec :: new ( ) ;
919- let m;
920- {
919+ let ( possible_evictions, m) = {
921920 let map = self . map_internal . read ( ) . unwrap ( ) ;
922- m = Measure :: start ( "flush_scan" ) ; // we don't care about lock time in this metric - bg threads can wait
923- Self :: gather_possible_evictions (
921+ let m = Measure :: start ( "flush_scan" ) ; // we don't care about lock time in this metric - bg threads can wait
922+ let possible_evictions = Self :: gather_possible_evictions (
924923 map. iter ( ) ,
925- & mut possible_evictions,
926924 startup,
927925 current_age,
928926 ages_flushing_now,
929927 ) ;
930- }
928+ ( possible_evictions, m)
929+ } ;
931930 Self :: update_time_stat ( & self . stats ( ) . flush_scan_us , m) ;
932931
933932 possible_evictions
@@ -1716,10 +1715,8 @@ mod tests {
17161715
17171716 for current_age in 0 ..=255 {
17181717 for ages_flushing_now in 0 ..=255 {
1719- let mut possible_evictions = Vec :: new ( ) ;
1720- InMemAccountsIndex :: < u64 , u64 > :: gather_possible_evictions (
1718+ let possible_evictions = InMemAccountsIndex :: < u64 , u64 > :: gather_possible_evictions (
17211719 map. iter ( ) ,
1722- & mut possible_evictions,
17231720 startup,
17241721 current_age,
17251722 ages_flushing_now,
0 commit comments