Fix clang-tidy performance-move-const-argument warnings (moving const variables)

This commit is contained in:
Tim Wojtulewicz 2025-04-25 15:12:40 -07:00
parent 6196950567
commit 144a3dee3a
9 changed files with 13 additions and 12 deletions

View file

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

View file

@ -52,7 +52,7 @@ void DataBlockList::Delete(DataBlockMap::const_iterator it) {
} }
DataBlock DataBlockList::Remove(DataBlockMap::const_iterator it) { DataBlock DataBlockList::Remove(DataBlockMap::const_iterator it) {
auto b = std::move(it->second); auto b = it->second;
auto size = b.Size(); auto size = b.Size();
block_map.erase(it); block_map.erase(it);

View file

@ -2348,7 +2348,7 @@ TypePtr merge_record_types(const Type* t1, const Type* t2) {
attrs3->AddAttrs(td2->attrs); attrs3->AddAttrs(td2->attrs);
attrs3->AddAttr(make_intrusive<detail::Attr>(detail::ATTR_OPTIONAL)); attrs3->AddAttr(make_intrusive<detail::Attr>(detail::ATTR_OPTIONAL));
auto td_merge = new TypeDecl(util::copy_string(td2->id), std::move(td2->type), attrs3); auto td_merge = new TypeDecl(util::copy_string(td2->id), td2->type, attrs3);
tdl3->push_back(td_merge); tdl3->push_back(td_merge);
} }
} }

View file

@ -131,7 +131,7 @@ void SSL_Analyzer::SetKeys(const zeek::StringVal& nkeys) {
std::copy(nkeys.Bytes(), nkeys.Bytes() + nkeys.Len(), std::back_inserter(keys)); std::copy(nkeys.Bytes(), nkeys.Bytes() + nkeys.Len(), std::back_inserter(keys));
} }
void SSL_Analyzer::SetKeys(const std::vector<u_char> newkeys) { keys = std::move(newkeys); } void SSL_Analyzer::SetKeys(std::vector<u_char> newkeys) { keys = std::move(newkeys); }
std::optional<std::vector<u_char>> SSL_Analyzer::TLS12_PRF(const std::string& secret, const std::string& label, std::optional<std::vector<u_char>> SSL_Analyzer::TLS12_PRF(const std::string& secret, const std::string& label,
const std::string& rnd1, const std::string& rnd2, const std::string& rnd1, const std::string& rnd2,

View file

@ -90,7 +90,7 @@ public:
* @param keys The key buffer as derived via TLS PRF (for * @param keys The key buffer as derived via TLS PRF (for
* AES_GCM this should be 72 bytes in length) * AES_GCM this should be 72 bytes in length)
*/ */
void SetKeys(const std::vector<u_char> newkeys); void SetKeys(std::vector<u_char> newkeys);
/** /**
* Check if the connection is flipped--meaning that the TLS client is the responder of the * Check if the connection is flipped--meaning that the TLS client is the responder of the

View file

@ -198,13 +198,13 @@ struct val_converter {
if ( disambiguate ) { if ( disambiguate ) {
// Disambiguate from composite key w/ multiple vals. // Disambiguate from composite key w/ multiple vals.
composite_key.emplace_back(std::move(item)); composite_key.emplace_back(item);
indices = &composite_key; indices = &composite_key;
} }
} }
} }
else { else {
composite_key.emplace_back(std::move(item)); composite_key.emplace_back(item);
indices = &composite_key; indices = &composite_key;
} }
@ -247,13 +247,13 @@ struct val_converter {
if ( disambiguate ) { if ( disambiguate ) {
// Disambiguate from composite key w/ multiple vals. // Disambiguate from composite key w/ multiple vals.
composite_key.emplace_back(std::move(item.first)); composite_key.emplace_back(item.first);
indices = &composite_key; indices = &composite_key;
} }
} }
} }
else { else {
composite_key.emplace_back(std::move(item.first)); composite_key.emplace_back(item.first);
indices = &composite_key; indices = &composite_key;
} }
@ -1036,7 +1036,7 @@ IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::DataVal)
std::optional<BrokerData> DataVal::DoSerializeData() const { return BrokerData{data}; } std::optional<BrokerData> DataVal::DoSerializeData() const { return BrokerData{data}; }
bool DataVal::DoUnserializeData(BrokerDataView dv) { bool DataVal::DoUnserializeData(BrokerDataView dv) {
data = std::move(*dv.value_); data = *dv.value_;
return true; return true;
} }

View file

@ -317,7 +317,7 @@ void Manager::ActivateDynamicPlugin(const std::string& name) {
UpdateInputFiles(); UpdateInputFiles();
else else
// Reschedule for another attempt later. // Reschedule for another attempt later.
requested_plugins.insert(std::move(name)); requested_plugins.insert(name);
} }
void Manager::ActivateDynamicPlugins(bool all) { void Manager::ActivateDynamicPlugins(bool all) {

View file

@ -127,7 +127,7 @@ void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e, const std::vector<
// This needs to come after filling out the confluence // This needs to come after filling out the confluence
// blocks, since they'll create their own (earlier) regions. // blocks, since they'll create their own (earlier) regions.
usage_regions.emplace_back(s, true, stmt_num); usage_regions.emplace_back(s, true, stmt_num);
usage_regions.back().SetDefExpr(std::move(e)); usage_regions.back().SetDefExpr(e);
if ( tracing ) if ( tracing )
DumpBlocks(); DumpBlocks();

View file

@ -711,7 +711,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
plugin_mgr->ExtendZeekPathForPlugins(); plugin_mgr->ExtendZeekPathForPlugins();
for ( const auto& x : requested_plugins ) for ( const auto& x : requested_plugins )
plugin_mgr->ActivateDynamicPlugin(std::move(x)); plugin_mgr->ActivateDynamicPlugin(x);
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode); plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);