Skip to content

Commit 5b0e197

Browse files
committed
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()`.
1 parent c44d84d commit 5b0e197

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcollections/vec_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl<V> VecMap<V> {
367367
// Move all elements to other
368368
swap(self, &mut other);
369369
return other
370-
} else if at > self.v.len() {
370+
} else if at >= self.v.len() {
371371
// No elements to copy
372372
return other;
373373
}

0 commit comments

Comments
 (0)