Skip to content

Commit

Permalink
refactor: Fix remaining clang-tidy performance-inefficient-vector errors
Browse files Browse the repository at this point in the history
  • Loading branch information
l0rinc committed Nov 25, 2024
1 parent 2638fdb commit a774c7a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rpc/output_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static RPCHelpMan createmultisig()
// Get the public keys
const UniValue& keys = request.params[1].get_array();
std::vector<CPubKey> pubkeys;
pubkeys.reserve(keys.size());
for (unsigned int i = 0; i < keys.size(); ++i) {
pubkeys.push_back(HexToPubKey(keys[i].get_str()));
}
Expand Down
1 change: 1 addition & 0 deletions src/test/checkqueue_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
{
std::vector<std::thread> tg;
tg.reserve(3);
std::atomic<int> nThreads {0};
std::atomic<int> fails {0};
for (size_t i = 0; i < 3; ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/test/cuckoocache_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void test_cache_erase_parallel(size_t megabytes)
/** Spin up 3 threads to run contains with erase.
*/
std::vector<std::thread> threads;
threads.reserve(3);
/** Erase the first quarter */
for (uint32_t x = 0; x < 3; ++x)
/** Each thread is emplaced with x copy-by-value
Expand Down
1 change: 1 addition & 0 deletions src/test/rpc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ BOOST_AUTO_TEST_CASE(rpc_getblockstats_calculate_percentiles_by_weight)
{
int64_t total_weight = 200;
std::vector<std::pair<CAmount, int64_t>> feerates;
feerates.reserve(200);
CAmount result[NUM_GETBLOCKSTATS_PERCENTILES] = { 0 };

for (int64_t i = 0; i < 100; i++) {
Expand Down

0 comments on commit a774c7a

Please sign in to comment.