[Bf-blender-cvs] [d71f96073f0] master: BLI: improve Vector.remove_and_reorder
Jacques Lucke
noreply at git.blender.org
Wed Apr 28 10:27:59 CEST 2021
Commit: d71f96073f090072bbcd9ac3d489c6ed58389574
Author: Jacques Lucke
Date: Wed Apr 28 10:27:49 2021 +0200
Branches: master
https://developer.blender.org/rBd71f96073f090072bbcd9ac3d489c6ed58389574
BLI: improve Vector.remove_and_reorder
The old version was correct as well but did a move even when not necessary.
===================================================================
M source/blender/blenlib/BLI_vector.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index 3a2f284a63b..8bea2584ca7 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -740,11 +740,12 @@ class Vector {
BLI_assert(index >= 0);
BLI_assert(index < this->size());
T *element_to_remove = begin_ + index;
- if (element_to_remove < end_) {
- *element_to_remove = std::move(*(end_ - 1));
+ T *last_element = end_ - 1;
+ if (element_to_remove < last_element) {
+ *element_to_remove = std::move(*last_element);
}
- end_--;
- end_->~T();
+ end_ = last_element;
+ last_element->~T();
UPDATE_VECTOR_SIZE(this);
}
More information about the Bf-blender-cvs
mailing list