collections: Fix conditional when reserving extra vec space

This commit is contained in:
Erick Tryzelaar 2014-07-03 08:45:28 -07:00 committed by Alex Crichton
parent e7adb8434a
commit 451b7495b0

View File

@ -496,7 +496,7 @@ impl<T> Vec<T> {
/// 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))
}
}