Merge pull request #4485 from sanxiyn/use-truncate
Use vec::truncate for vec::retain
This commit is contained in:
commit
0ca369e9dc
1 changed files with 2 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue