File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,16 @@ pub struct AllocationStats {
3434impl AllocationStats {
3535 /// Record that an allocation was made.
3636 pub ( crate ) fn record_allocation ( & self ) {
37- self . num_alloc . set ( self . num_alloc . get ( ) + 1 ) ;
37+ // Counter maxes out at `usize::MAX`, but if there's that many allocations,
38+ // the exact number is not important
39+ self . num_alloc . set ( self . num_alloc . get ( ) . saturating_add ( 1 ) ) ;
3840 }
3941
4042 /// Record that a reallocation was made.
4143 pub ( crate ) fn record_reallocation ( & self ) {
42- self . num_realloc . set ( self . num_realloc . get ( ) + 1 ) ;
44+ // Counter maxes out at `usize::MAX`, but if there's that many allocations,
45+ // the exact number is not important
46+ self . num_realloc . set ( self . num_realloc . get ( ) . saturating_add ( 1 ) ) ;
4347 }
4448
4549 /// Reset allocation counters.
You can’t perform that action at this time.
0 commit comments