mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 22:42:04 +01:00
refactor: rpc: Remove vector copy from listtransactions
No change in behavior.
This commit is contained in:
parent
ddecb671f0
commit
25bc17fceb
1 changed files with 4 additions and 17 deletions
|
@ -1491,23 +1491,10 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
|||
if ((nFrom + nCount) > (int)ret.size())
|
||||
nCount = ret.size() - nFrom;
|
||||
|
||||
std::vector<UniValue> arrTmp = ret.getValues();
|
||||
|
||||
std::vector<UniValue>::iterator first = arrTmp.begin();
|
||||
std::advance(first, nFrom);
|
||||
std::vector<UniValue>::iterator last = arrTmp.begin();
|
||||
std::advance(last, nFrom+nCount);
|
||||
|
||||
if (last != arrTmp.end()) arrTmp.erase(last, arrTmp.end());
|
||||
if (first != arrTmp.begin()) arrTmp.erase(arrTmp.begin(), first);
|
||||
|
||||
std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest
|
||||
|
||||
ret.clear();
|
||||
ret.setArray();
|
||||
ret.push_backV(arrTmp);
|
||||
|
||||
return ret;
|
||||
const std::vector<UniValue>& txs = ret.getValues();
|
||||
UniValue result{UniValue::VARR};
|
||||
result.push_backV({ txs.rend() - nFrom - nCount, txs.rend() - nFrom }); // Return oldest to newest
|
||||
return result;
|
||||
}
|
||||
|
||||
static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
|
|
Loading…
Add table
Reference in a new issue