File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ impl IslandManager {
37
37
}
38
38
39
39
pub ( crate ) fn num_islands ( & self ) -> usize {
40
- self . active_islands . len ( ) - 1
40
+ self . active_islands . len ( ) . saturating_sub ( 1 )
41
41
}
42
42
43
43
/// Update this data-structure after one or multiple rigid-bodies have been removed for `bodies`.
@@ -244,8 +244,8 @@ impl IslandManager {
244
244
self . active_islands . clear ( ) ;
245
245
self . active_islands . push ( 0 ) ;
246
246
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 ) ;
249
249
250
250
// NOTE: islands containing a body with non-standard number of iterations won’t
251
251
// 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 {
58
58
let range = self . groups [ i] ..self . groups [ i + 1 ] ;
59
59
& self . sorted_interactions [ range]
60
60
}
61
+
61
62
pub fn num_groups ( & self ) -> usize {
62
- self . groups . len ( ) - 1
63
+ self . groups . len ( ) . saturating_sub ( 1 )
63
64
}
64
65
65
66
pub fn group_interactions < Interaction : PairInteraction > (
You can’t perform that action at this time.
0 commit comments