@@ -71,11 +71,9 @@ pub fn search_inplace<I: Index, R: Real>(
7171/// Allocates enough storage for the given number of particles and clears all existing neighborhood lists
7272fn init_neighborhood_list ( neighborhood_list : & mut Vec < Vec < usize > > , new_len : usize ) {
7373 let old_len = neighborhood_list. len ( ) ;
74- if old_len != new_len {
75- // Reset all neighbor lists that won't be truncated
76- for particle_list in neighborhood_list. iter_mut ( ) . take ( old_len. min ( new_len) ) {
77- particle_list. clear ( ) ;
78- }
74+ // Reset all neighbor lists that won't be truncated
75+ for particle_list in neighborhood_list. iter_mut ( ) . take ( old_len. min ( new_len) ) {
76+ particle_list. clear ( ) ;
7977 }
8078
8179 // Ensure that length is correct
@@ -85,15 +83,14 @@ fn init_neighborhood_list(neighborhood_list: &mut Vec<Vec<usize>>, new_len: usiz
8583/// Allocates enough storage for the given number of particles and clears all existing neighborhood lists in parallel
8684fn par_init_neighborhood_list ( neighborhood_list : & mut Vec < Vec < usize > > , new_len : usize ) {
8785 let old_len = neighborhood_list. len ( ) ;
88- if old_len != new_len {
89- // Reset all neighbor lists that won't be truncated
90- neighborhood_list
91- . par_iter_mut ( )
92- . take ( old_len. min ( new_len) )
93- . for_each ( |particle_list| {
94- particle_list. clear ( ) ;
95- } ) ;
96- }
86+ // Reset all neighbor lists that won't be truncated
87+ neighborhood_list
88+ . par_iter_mut ( )
89+ . with_min_len ( 8 )
90+ . take ( old_len. min ( new_len) )
91+ . for_each ( |particle_list| {
92+ particle_list. clear ( ) ;
93+ } ) ;
9794
9895 // Ensure that length is correct
9996 neighborhood_list. resize_with ( new_len, || Vec :: with_capacity ( 15 ) ) ;
0 commit comments