mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-06 08:41:10 +01:00
Move removeIndex's result instead of copying (#1516)
Currently removeIndex copies the removed value into removed and then destructs the original, which can cause significant performance overhead. Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
This commit is contained in:
parent
8d1ea7054f
commit
fdb529bd06
@ -1205,7 +1205,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (removed)
|
if (removed)
|
||||||
*removed = it->second;
|
*removed = std::move(it->second);
|
||||||
ArrayIndex oldSize = size();
|
ArrayIndex oldSize = size();
|
||||||
// shift left all items left, into the place of the "removed"
|
// shift left all items left, into the place of the "removed"
|
||||||
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
|
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user