Skip to content

Commit

Permalink
Fix the new capacity measurement in arenas.
Browse files Browse the repository at this point in the history
For the given code paths, the amount of space used in the previous chunk
is irrelevant.

(This will almost never make a difference to behaviour, but it makes the
code clearer.)
  • Loading branch information
nnethercote committed May 13, 2020
1 parent 99cb9cc commit 9111d8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<T> TypedArena<T> {
new_capacity = last_chunk.storage.capacity();
loop {
new_capacity = new_capacity.checked_mul(2).unwrap();
if new_capacity >= currently_used_cap + n {
if new_capacity >= n {
break;
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@ impl DroplessArena {
new_capacity = last_chunk.storage.capacity();
loop {
new_capacity = new_capacity.checked_mul(2).unwrap();
if new_capacity >= used_bytes + needed_bytes {
if new_capacity >= needed_bytes {
break;
}
}
Expand Down

0 comments on commit 9111d8b

Please sign in to comment.