File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
starlark/src/values/layout/heap Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,11 @@ impl<'c> Iterator for ChunkIter<'c> {
140140}
141141
142142impl Arena {
143+ /// Number of allocated bytes plus padding size.
143144 pub fn allocated_bytes ( & self ) -> usize {
145+ // This overestimates the allocates size, see `Bump::allocated_bytes()`:
146+ // "those padding bytes will add to this method’s resulting sum".
147+ // https://docs.rs/bumpalo/3.11.0/bumpalo/struct.Bump.html#method.allocated_bytes
144148 self . drop . allocated_bytes ( ) + self . non_drop . allocated_bytes ( )
145149 }
146150
@@ -510,6 +514,7 @@ mod tests {
510514 assert_eq ! ( res. len( ) , 1 ) ;
511515 let entry = res. values ( ) . next ( ) . unwrap ( ) ;
512516 assert_eq ! ( entry. count, 2 ) ;
513- assert_eq ! ( entry. bytes, arena. allocated_bytes( ) ) ;
517+ // Because `arena.allocated_bytes` over-approximates.
518+ assert ! ( entry. bytes <= arena. allocated_bytes( ) ) ;
514519 }
515520}
You can’t perform that action at this time.
0 commit comments