about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohannes Oertel <johannes.oertel@uni-due.de>2015-05-11 12:54:59 +0200
committerJohannes Oertel <johannes.oertel@uni-due.de>2015-05-11 12:54:59 +0200
commit5b0e19794efe6d2d7f225df57505205627103f32 (patch)
tree6e473c7b378b14ec770f098b20e7070d16ef5225
parentc44d84da981c14cdaa144aa7b0f1109578ed72c3 (diff)
downloadrust-5b0e19794efe6d2d7f225df57505205627103f32.tar.gz
rust-5b0e19794efe6d2d7f225df57505205627103f32.zip
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()`.
-rw-r--r--src/libcollections/vec_map.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index 6ff819fc87c..aa0ab41b745 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -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;
         }