@@ -202,17 +202,10 @@ impl<T> VecDeque<T> {
202
202
len) ;
203
203
}
204
204
205
- /// Copies all values from `src` to the back of `self`, wrapping around if needed.
206
- ///
207
- /// # Safety
208
- ///
209
- /// The capacity must be sufficient to hold self.len() + src.len() elements.
210
- /// If so, this function never panics.
205
+ /// Copies all values from `src` to `self`, wrapping around if needed.
206
+ /// Assumes capacity is sufficient.
211
207
#[ inline]
212
208
unsafe fn copy_slice ( & mut self , src : & [ T ] ) {
213
- let expected_new_len = self . len ( ) + src. len ( ) ;
214
- debug_assert ! ( self . capacity( ) >= expected_new_len) ;
215
-
216
209
let dst_high_ptr = self . ptr ( ) . add ( self . head ) ;
217
210
let dst_high_len = self . cap ( ) - self . head ;
218
211
@@ -223,7 +216,6 @@ impl<T> VecDeque<T> {
223
216
ptr:: copy_nonoverlapping ( src_low. as_ptr ( ) , self . ptr ( ) , src_low. len ( ) ) ;
224
217
225
218
self . head = self . wrap_add ( self . head , src. len ( ) ) ;
226
- debug_assert ! ( self . len( ) == expected_new_len) ;
227
219
}
228
220
229
221
/// Copies a potentially wrapping block of memory len long from src to dest.
@@ -1858,21 +1850,17 @@ impl<T> VecDeque<T> {
1858
1850
#[ inline]
1859
1851
#[ stable( feature = "append" , since = "1.4.0" ) ]
1860
1852
pub fn append ( & mut self , other : & mut Self ) {
1861
- unsafe {
1862
- // Guarantees there is space in `self` for `other`.
1863
- self . reserve ( other. len ( ) ) ;
1864
-
1865
- {
1866
- let ( src_high, src_low) = other. as_slices ( ) ;
1853
+ // Guarantees there is space in `self` for `other
1854
+ self . reserve ( other. len ( ) ) ;
1867
1855
1868
- // This is only safe because copy_slice never panics when capacity is sufficient.
1869
- self . copy_slice ( src_low) ;
1870
- self . copy_slice ( src_high) ;
1871
- }
1872
-
1873
- // Some values now exist in both `other` and `self` but are made inaccessible in `other`.
1874
- other. tail = other. head ;
1856
+ unsafe {
1857
+ let ( src_high, src_low) = other. as_slices ( ) ;
1858
+ self . copy_slice ( src_low) ;
1859
+ self . copy_slice ( src_high) ;
1875
1860
}
1861
+
1862
+ // Some values now exist in both `other` and `self` but are made inaccessible in `other`.
1863
+ other. tail = other. head ;
1876
1864
}
1877
1865
1878
1866
/// Retains only the elements specified by the predicate.
0 commit comments