Skip to content

Commit fdb529b

Browse files
jedavbaylesj
andauthored
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>
1 parent 8d1ea70 commit fdb529b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib_json/json_value.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
12051205
return false;
12061206
}
12071207
if (removed)
1208-
*removed = it->second;
1208+
*removed = std::move(it->second);
12091209
ArrayIndex oldSize = size();
12101210
// shift left all items left, into the place of the "removed"
12111211
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {

0 commit comments

Comments
 (0)