@@ -98,7 +98,7 @@ impl<T> VecDeque<T> {
98
98
// For zero sized types, we are always at maximum capacity
99
99
MAXIMUM_ZST_CAPACITY
100
100
} else {
101
- self . buf . cap ( )
101
+ self . buf . capacity ( )
102
102
}
103
103
}
104
104
@@ -314,10 +314,10 @@ impl<T> VecDeque<T> {
314
314
}
315
315
316
316
/// Frobs the head and tail sections around to handle the fact that we
317
- /// just reallocated. Unsafe because it trusts old_cap .
317
+ /// just reallocated. Unsafe because it trusts old_capacity .
318
318
#[ inline]
319
- unsafe fn handle_cap_increase ( & mut self , old_cap : usize ) {
320
- let new_cap = self . cap ( ) ;
319
+ unsafe fn handle_capacity_increase ( & mut self , old_capacity : usize ) {
320
+ let new_capacity = self . cap ( ) ;
321
321
322
322
// Move the shortest contiguous section of the ring buffer
323
323
// T H
@@ -336,15 +336,15 @@ impl<T> VecDeque<T> {
336
336
if self . tail <= self . head {
337
337
// A
338
338
// Nop
339
- } else if self . head < old_cap - self . tail {
339
+ } else if self . head < old_capacity - self . tail {
340
340
// B
341
- self . copy_nonoverlapping ( old_cap , 0 , self . head ) ;
342
- self . head += old_cap ;
341
+ self . copy_nonoverlapping ( old_capacity , 0 , self . head ) ;
342
+ self . head += old_capacity ;
343
343
debug_assert ! ( self . head > self . tail) ;
344
344
} else {
345
345
// C
346
- let new_tail = new_cap - ( old_cap - self . tail ) ;
347
- self . copy_nonoverlapping ( new_tail, self . tail , old_cap - self . tail ) ;
346
+ let new_tail = new_capacity - ( old_capacity - self . tail ) ;
347
+ self . copy_nonoverlapping ( new_tail, self . tail , old_capacity - self . tail ) ;
348
348
self . tail = new_tail;
349
349
debug_assert ! ( self . head < self . tail) ;
350
350
}
@@ -551,7 +551,7 @@ impl<T> VecDeque<T> {
551
551
if new_cap > old_cap {
552
552
self . buf . reserve_exact ( used_cap, new_cap - used_cap) ;
553
553
unsafe {
554
- self . handle_cap_increase ( old_cap) ;
554
+ self . handle_capacity_increase ( old_cap) ;
555
555
}
556
556
}
557
557
}
@@ -641,7 +641,7 @@ impl<T> VecDeque<T> {
641
641
if new_cap > old_cap {
642
642
self . buf . try_reserve_exact ( used_cap, new_cap - used_cap) ?;
643
643
unsafe {
644
- self . handle_cap_increase ( old_cap) ;
644
+ self . handle_capacity_increase ( old_cap) ;
645
645
}
646
646
}
647
647
Ok ( ( ) )
@@ -1873,7 +1873,7 @@ impl<T> VecDeque<T> {
1873
1873
let old_cap = self . cap ( ) ;
1874
1874
self . buf . double ( ) ;
1875
1875
unsafe {
1876
- self . handle_cap_increase ( old_cap) ;
1876
+ self . handle_capacity_increase ( old_cap) ;
1877
1877
}
1878
1878
debug_assert ! ( !self . is_full( ) ) ;
1879
1879
}
@@ -2708,9 +2708,9 @@ impl<T> From<Vec<T>> for VecDeque<T> {
2708
2708
2709
2709
// We need to extend the buf if it's not a power of two, too small
2710
2710
// or doesn't have at least one free space
2711
- if !buf. cap ( ) . is_power_of_two ( ) || ( buf. cap ( ) < ( MINIMUM_CAPACITY + 1 ) ) ||
2712
- ( buf. cap ( ) == len) {
2713
- let cap = cmp:: max ( buf. cap ( ) + 1 , MINIMUM_CAPACITY + 1 ) . next_power_of_two ( ) ;
2711
+ if !buf. capacity ( ) . is_power_of_two ( ) || ( buf. capacity ( ) < ( MINIMUM_CAPACITY + 1 ) ) ||
2712
+ ( buf. capacity ( ) == len) {
2713
+ let cap = cmp:: max ( buf. capacity ( ) + 1 , MINIMUM_CAPACITY + 1 ) . next_power_of_two ( ) ;
2714
2714
buf. reserve_exact ( len, cap - len) ;
2715
2715
}
2716
2716
@@ -3096,8 +3096,8 @@ mod tests {
3096
3096
fn test_vec_from_vecdeque ( ) {
3097
3097
use crate :: vec:: Vec ;
3098
3098
3099
- fn create_vec_and_test_convert ( cap : usize , offset : usize , len : usize ) {
3100
- let mut vd = VecDeque :: with_capacity ( cap ) ;
3099
+ fn create_vec_and_test_convert ( capacity : usize , offset : usize , len : usize ) {
3100
+ let mut vd = VecDeque :: with_capacity ( capacity ) ;
3101
3101
for _ in 0 ..offset {
3102
3102
vd. push_back ( 0 ) ;
3103
3103
vd. pop_front ( ) ;
0 commit comments