From 4e73664f9e480977bb278147c1c03b42a3b67498 Mon Sep 17 00:00:00 2001 From: jedav Date: Tue, 17 Oct 2023 14:32:11 -0700 Subject: [PATCH] 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. --- src/lib_json/json_value.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index aa2b744ca..a3dee3422 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -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) {