From 5b0e19794efe6d2d7f225df57505205627103f32 Mon Sep 17 00:00:00 2001 From: Johannes Oertel Date: Mon, 11 May 2015 12:54:59 +0200 Subject: [PATCH] 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()`. --- src/libcollections/vec_map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 6ff819fc87cdb..aa0ab41b7455b 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -367,7 +367,7 @@ impl VecMap { // 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; }