Merge bitcoin/bitcoin#25237: rpc: Capture UniValue by ref for rpcdoccheck

20ff4991e5 rpc: Capture potentially large UniValue by ref for rpcdoccheck (Martin Zumsande)

Pull request description:

  Capturing it by reference instead of value should save us from making a copy of a potentially large object. Saw this while having a look at #25229 although I couldn't reproduce an actual leak, so this is not a fix for that issue.

ACKs for top commit:
  MarcoFalke:
    review ACK 20ff4991e5
  theStack:
    Code-review ACK 20ff4991e5
  furszy:
    Code ACK 20ff4991

Tree-SHA512: faf7bb14e37f8324b93a39095b07693626329da47c4a1ac8929bf99385e2e0567008e959e7e8540bc7d454d08fa41cccd39f55253c9a839fa88362922058a93b
This commit is contained in:
fanquake 2022-05-30 09:15:50 +01:00
commit e3b7f10b10
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -583,7 +583,7 @@ UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) const
} }
const UniValue ret = m_fun(*this, request); const UniValue ret = m_fun(*this, request);
if (gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) { if (gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) {
CHECK_NONFATAL(std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [ret](const RPCResult& res) { return res.MatchesType(ret); })); CHECK_NONFATAL(std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [&ret](const RPCResult& res) { return res.MatchesType(ret); }));
} }
return ret; return ret;
} }