Skip to content

Commit 90baa0e

Browse files
committed
---
yaml --- r: 272751 b: refs/heads/beta c: f6e125f h: refs/heads/master i: 272749: e048122 272747: 6b9748e 272743: e534909 272735: cad5a66
1 parent dbeb546 commit 90baa0e

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 37ba66a66e07ce62a743b61f83d1b7bf38f1f88b
26+
refs/heads/beta: f6e125f04a54ec65eac0ecd3cb68e180210a06fa
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libcollections/vec.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use borrow::ToOwned;
6666
use core::cmp::Ordering;
6767
use core::fmt;
6868
use core::hash::{self, Hash};
69-
use core::intrinsics::{arith_offset, assume, needs_drop};
69+
use core::intrinsics::{arith_offset, assume};
7070
use core::iter::FromIterator;
7171
use core::mem;
7272
use core::ops::{Index, IndexMut};
@@ -497,10 +497,11 @@ impl<T> Vec<T> {
497497
unsafe {
498498
// drop any extra elements
499499
while len < self.len {
500-
// decrement len before the read(), so a panic on Drop doesn't
501-
// re-drop the just-failed value.
500+
// decrement len before the drop_in_place(), so a panic on Drop
501+
// doesn't re-drop the just-failed value.
502502
self.len -= 1;
503-
ptr::read(self.get_unchecked(self.len));
503+
let len = self.len;
504+
ptr::drop_in_place(self.get_unchecked_mut(len));
504505
}
505506
}
506507
}
@@ -1471,13 +1472,8 @@ impl<T> Drop for Vec<T> {
14711472
fn drop(&mut self) {
14721473
if self.buf.unsafe_no_drop_flag_needs_drop() {
14731474
unsafe {
1474-
// The branch on needs_drop() is an -O1 performance optimization.
1475-
// Without the branch, dropping Vec<u8> takes linear time.
1476-
if needs_drop::<T>() {
1477-
for x in self.iter_mut() {
1478-
ptr::drop_in_place(x);
1479-
}
1480-
}
1475+
// use drop for [T]
1476+
ptr::drop_in_place(&mut self[..]);
14811477
}
14821478
}
14831479
// RawVec handles deallocation

branches/beta/src/libcollections/vec_deque.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ impl<T: Clone> Clone for VecDeque<T> {
7070
impl<T> Drop for VecDeque<T> {
7171
#[unsafe_destructor_blind_to_params]
7272
fn drop(&mut self) {
73-
self.clear();
73+
let (front, back) = self.as_mut_slices();
74+
unsafe {
75+
// use drop for [T]
76+
ptr::drop_in_place(front);
77+
ptr::drop_in_place(back);
78+
}
7479
// RawVec handles deallocation
7580
}
7681
}

0 commit comments

Comments
 (0)