]> git.lizzy.rs Git - rust.git/commitdiff
Use vec::truncate for vec::retain
authorSeo Sanghyeon <sanxiyn@gmail.com>
Mon, 14 Jan 2013 10:45:08 +0000 (19:45 +0900)
committerSeo Sanghyeon <sanxiyn@gmail.com>
Mon, 14 Jan 2013 10:45:08 +0000 (19:45 +0900)
src/libcore/vec.rs

index 9527c85481c276b84ad32dd1816556268f48e45c..3ecfe100c46af62ae95cf726f5c5d0d470689246 100644 (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);
     }
 }