Move removeIndex's result instead of copying

Currently removeIndex copies the removed value into removed and then
destructs the original, which can cause significant performance overhead.
This commit is contained in:
jedav 2023-10-17 14:32:11 -07:00
parent 69098a18b9
commit 4e73664f9e

View File

@ -1205,7 +1205,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
return false;
}
if (removed)
*removed = it->second;
*removed = std::move(it->second);
ArrayIndex oldSize = size();
// shift left all items left, into the place of the "removed"
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {