refactor: Fix remaining clang-tidy performance-inefficient-vector errors

This commit is contained in:
Lőrinc 2024-11-17 13:53:35 +01:00
parent 2638fdb4f9
commit a774c7a339
4 changed files with 4 additions and 0 deletions

View File

@ -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()));
}

View File

@ -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) {

View File

@ -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

View File

@ -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++) {