diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2020-05-04 17:17:07 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2020-05-13 11:29:16 +1000 |
| commit | 9111d8b66e013a881bae4e09646514be86ca4c87 (patch) | |
| tree | 98ddc755bde9d771bfc1874613b98b96b636a79f | |
| parent | 99cb9ccb9ca2067ad6e60508e3d52da77396b2f1 (diff) | |
| download | rust-9111d8b66e013a881bae4e09646514be86ca4c87.tar.gz rust-9111d8b66e013a881bae4e09646514be86ca4c87.zip | |
Fix the new capacity measurement in arenas.
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.)
| -rw-r--r-- | src/libarena/lib.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 0f0bd617f43..b42a2e711ac 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -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; } } @@ -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; } } |
