File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ impl IslandManager {
3737 }
3838
3939 pub ( crate ) fn num_islands ( & self ) -> usize {
40- self . active_islands . len ( ) - 1
40+ self . active_islands . len ( ) . saturating_sub ( 1 )
4141 }
4242
4343 /// Update this data-structure after one or multiple rigid-bodies have been removed for `bodies`.
@@ -244,8 +244,8 @@ impl IslandManager {
244244 self . active_islands . clear ( ) ;
245245 self . active_islands . push ( 0 ) ;
246246
247- // The max avoid underflow when the stack is empty.
248- let mut island_marker = self . stack . len ( ) . max ( 1 ) - 1 ;
247+ // saturating_sub(1) prevents underflow when the stack is empty.
248+ let mut island_marker = self . stack . len ( ) . saturating_sub ( 1 ) ;
249249
250250 // NOTE: islands containing a body with non-standard number of iterations won’t
251251 // be merged with another island, unless another island with standard
Original file line number Diff line number Diff line change @@ -58,8 +58,9 @@ impl ParallelInteractionGroups {
5858 let range = self . groups [ i] ..self . groups [ i + 1 ] ;
5959 & self . sorted_interactions [ range]
6060 }
61+
6162 pub fn num_groups ( & self ) -> usize {
62- self . groups . len ( ) - 1
63+ self . groups . len ( ) . saturating_sub ( 1 )
6364 }
6465
6566 pub fn group_interactions < Interaction : PairInteraction > (
You can’t perform that action at this time.
0 commit comments