Skip to content

Commit 9a41cfa

Browse files
committed
Revert "Add docs and debug asserts"
This reverts commit 1a1a7f6.
1 parent 5444148 commit 9a41cfa

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/liballoc/collections/vec_deque.rs

+11-23
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,10 @@ impl<T> VecDeque<T> {
202202
len);
203203
}
204204

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.
211207
#[inline]
212208
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-
216209
let dst_high_ptr = self.ptr().add(self.head);
217210
let dst_high_len = self.cap() - self.head;
218211

@@ -223,7 +216,6 @@ impl<T> VecDeque<T> {
223216
ptr::copy_nonoverlapping(src_low.as_ptr(), self.ptr(), src_low.len());
224217

225218
self.head = self.wrap_add(self.head, src.len());
226-
debug_assert!(self.len() == expected_new_len);
227219
}
228220

229221
/// Copies a potentially wrapping block of memory len long from src to dest.
@@ -1858,21 +1850,17 @@ impl<T> VecDeque<T> {
18581850
#[inline]
18591851
#[stable(feature = "append", since = "1.4.0")]
18601852
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());
18671855

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);
18751860
}
1861+
1862+
// Some values now exist in both `other` and `self` but are made inaccessible in `other`.
1863+
other.tail = other.head;
18761864
}
18771865

18781866
/// Retains only the elements specified by the predicate.

0 commit comments

Comments
 (0)