rpc: Avoid copies in JSONRPCReplyObj()

Change parameters from const references to values, so they can be moved into
the reply instead of copied. Also update callers to move instead of copy.
This commit is contained in:
Matthew Zipkin
2024-01-23 10:33:26 -05:00
committed by Ryan Ofsky
parent 09416f9ec4
commit df6e3756d6
5 changed files with 16 additions and 23 deletions

View File

@@ -366,11 +366,11 @@ static UniValue JSONRPCExecOne(JSONRPCRequest jreq, const UniValue& req)
jreq.parse(req);
UniValue result = tableRPC.execute(jreq);
rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
rpc_result = JSONRPCReplyObj(std::move(result), NullUniValue, jreq.id);
}
catch (const UniValue& objError)
catch (UniValue& e)
{
rpc_result = JSONRPCReplyObj(NullUniValue, objError, jreq.id);
rpc_result = JSONRPCReplyObj(NullUniValue, std::move(e), jreq.id);
}
catch (const std::exception& e)
{