Skip to content

Commit fa94652

Browse files
author
MarcoFalke
committed
refactor: Use structured binding for-loop
1 parent eeeec15 commit fa94652

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/rpc/server.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2022 The Bitcoin Core developers
2+
// Copyright (c) 2009-present The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -21,6 +21,7 @@
2121
#include <util/time.h>
2222
#include <validation.h>
2323

24+
#include <algorithm>
2425
#include <cassert>
2526
#include <chrono>
2627
#include <memory>
@@ -79,15 +80,13 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
7980

8081
for (const auto& entry : mapCommands)
8182
vCommands.emplace_back(entry.second.front()->category + entry.first, entry.second.front());
82-
sort(vCommands.begin(), vCommands.end());
83+
std::ranges::sort(vCommands);
8384

8485
JSONRPCRequest jreq = helpreq;
8586
jreq.mode = JSONRPCRequest::GET_HELP;
8687
jreq.params = UniValue();
8788

88-
for (const std::pair<std::string, const CRPCCommand*>& command : vCommands)
89-
{
90-
const CRPCCommand *pcmd = command.second;
89+
for (const auto& [_, pcmd] : vCommands) {
9190
std::string strMethod = pcmd->name;
9291
if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
9392
continue;

0 commit comments

Comments
 (0)