Skip to content

Commit

Permalink
Minor optimization for VecMap::split_off
Browse files Browse the repository at this point in the history
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()`.
  • Loading branch information
jooert committed May 11, 2015
1 parent c44d84d commit 5b0e197
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcollections/vec_map.rs
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5b0e197

Please sign in to comment.