]> git.lizzy.rs Git - rust.git/commitdiff
collections: Fix conditional when reserving extra vec space
authorErick Tryzelaar <erick.tryzelaar@gmail.com>
Thu, 3 Jul 2014 15:45:28 +0000 (08:45 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 3 Jul 2014 19:54:52 +0000 (12:54 -0700)
src/libcollections/vec.rs

index b8efaa78af3a9eb68de96705236140e20c23e3ac..d53ecabd5a9cb147e5093e7ce172dd91acf1835a 100644 (file)
@@ -496,7 +496,7 @@ pub fn reserve_additional(&mut self, extra: uint) {
     /// assert!(vec.capacity() >= 10);
     /// ```
     pub fn reserve(&mut self, capacity: uint) {
-        if capacity >= self.len {
+        if capacity > self.cap {
             self.reserve_exact(num::next_power_of_two(capacity))
         }
     }