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>
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index 26cd843..a5e2dd8 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -1205,7 +1205,7 @@
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) {