@@ -614,7 +614,7 @@ impl<T: TransparentType> Slice<T> {
614
614
/// Reserves at least this much additional capacity.
615
615
pub fn reserve ( & mut self , additional : usize ) {
616
616
// Nothing new to reserve as there's still enough space
617
- if self . len + additional <= self . capacity {
617
+ if additional <= self . capacity - self . len {
618
618
return ;
619
619
}
620
620
@@ -685,7 +685,7 @@ impl<T: TransparentType> Slice<T> {
685
685
#[ inline]
686
686
pub fn extend_from_slice ( & mut self , other : & [ T ] ) {
687
687
// Nothing new to reserve as there's still enough space
688
- if self . len + other. len ( ) > self . capacity {
688
+ if other. len ( ) > self . capacity - self . len {
689
689
self . reserve ( other. len ( ) ) ;
690
690
}
691
691
@@ -706,7 +706,7 @@ impl<T: TransparentType> Slice<T> {
706
706
assert ! ( index <= self . len) ;
707
707
708
708
// Nothing new to reserve as there's still enough space
709
- if self . len + 1 > self . capacity {
709
+ if 1 > self . capacity - self . len {
710
710
self . reserve ( 1 ) ;
711
711
}
712
712
@@ -729,7 +729,7 @@ impl<T: TransparentType> Slice<T> {
729
729
#[ allow( clippy:: int_plus_one) ]
730
730
pub fn push ( & mut self , item : T ) {
731
731
// Nothing new to reserve as there's still enough space
732
- if self . len + 1 > self . capacity {
732
+ if 1 > self . capacity - self . len {
733
733
self . reserve ( 1 ) ;
734
734
}
735
735
0 commit comments