Minor optimization for VecMap::split_off

We don't need to copy any elements if `at` is behind the last element
in the map. The last element is at index `self.v.len() - 1`, so we
should not copy if `at` is greater or equals `self.v.len()`.
This commit is contained in:
Johannes Oertel 2015-05-11 12:54:59 +02:00
parent c44d84da98
commit 5b0e19794e

View File

@ -367,7 +367,7 @@ impl<V> VecMap<V> {
// Move all elements to other
swap(self, &mut other);
return other
} else if at > self.v.len() {
} else if at >= self.v.len() {
// No elements to copy
return other;
}