Skip to content

Commit 98b0a6c

Browse files
committed
Rename constant
1 parent 4202060 commit 98b0a6c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/alloc/src/raw_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<T, A: Allocator> RawVec<T, A> {
392392
// Size of allocator's per-allocation overhead we expect
393393
// FIXME: maybe two pointers to be on the safe side? It could potentially
394394
// be platform-dependent.
395-
let alloc_overhead_size = mem::size_of::<usize>();
395+
const ALLOC_OVERHEAD_SIZE: usize = mem::size_of::<usize>();
396396

397397
// Nothing we can really do about these checks, sadly.
398398
let required_cap = len.checked_add(additional).ok_or(CapacityOverflow)?;
@@ -401,7 +401,7 @@ impl<T, A: Allocator> RawVec<T, A> {
401401
.checked_mul(mem::size_of::<T>())
402402
.and_then(
403403
// Add the overhead
404-
|alloc_size| alloc_size.checked_add(alloc_overhead_size),
404+
|alloc_size| alloc_size.checked_add(ALLOC_OVERHEAD_SIZE),
405405
)
406406
.filter(|alloc_size| *alloc_size < isize::MAX as usize)
407407
{
@@ -414,7 +414,7 @@ impl<T, A: Allocator> RawVec<T, A> {
414414
// Leave some room for allocators that add fixed overhead (usually
415415
// one pointer-size)
416416
// `bin_size - ...` can't underflow, because alloc_overhead_size was already added
417-
let aligned_alloc_size = bin_size - (alloc_overhead_size - 1) /* the +1 skipped from the previous line turned into -1 here */ ;
417+
let aligned_alloc_size = bin_size - (ALLOC_OVERHEAD_SIZE - 1) /* the +1 skipped from the previous line turned into -1 here */ ;
418418

419419
// Align the capacity to fit the bin
420420
aligned_alloc_size / mem::size_of::<T>()

0 commit comments

Comments
 (0)