Fix clang-tidy performance-inefficient-vector-operation warnings

This commit is contained in:
Tim Wojtulewicz 2025-04-25 13:56:08 -07:00
parent b8e28abb97
commit 6196950567
4 changed files with 5 additions and 0 deletions

View file

@ -4,6 +4,7 @@ Checks: [-*,
performance-enum-size,
performance-faster-string-find,
performance-for-range-copy,
performance-inefficient-vector-operation,
# Skipping these temporarily because they are very noisy
-bugprone-narrowing-conversions,

View file

@ -678,6 +678,7 @@ void Manager::DoTerminate() {
iosource_mgr->UnregisterFd(bstate->loggerQueue->FlareFd(), this);
vector<string> stores_to_close;
stores_to_close.reserve(data_stores.size());
for ( auto& x : data_stores )
stores_to_close.push_back(x.first);

View file

@ -1056,6 +1056,8 @@ StmtPtr InitStmt::Duplicate() {
// Need to duplicate the initializer list since later reductions
// can modify it in place.
std::vector<IDPtr> new_inits;
new_inits.reserve(inits.size());
for ( const auto& id : inits )
new_inits.push_back(id);

View file

@ -942,6 +942,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
}
std::vector<SignatureFile> all_signature_files;
all_signature_files.reserve(options.signature_files.size() + zeek::detail::sig_files.size());
// Append signature files given on the command line
for ( const auto& sf : options.signature_files )