Merge pull request #4485 from sanxiyn/use-truncate

Use vec::truncate for vec::retain
This commit is contained in:
Brian Anderson 2013-01-14 14:11:26 -08:00
commit 0ca369e9dc

View File

@ -895,9 +895,8 @@ pub fn retain<T>(v: &mut ~[T], f: pure fn(t: &T) -> bool) {
}
}
while deleted > 0 {
v.pop();
deleted -= 1;
if deleted > 0 {
v.truncate(len - deleted);
}
}