Use const references over copying variables (performance-unnecessary-copy-initialization, performance-for-range-copy)

This commit is contained in:
Tim Wojtulewicz 2020-02-03 11:20:54 -05:00
parent c32566420a
commit eda1b4a23e
4 changed files with 5 additions and 6 deletions

View file

@ -961,8 +961,7 @@ IPAddr SubNetVal::Mask() const
bool SubNetVal::Contains(const IPAddr& addr) const bool SubNetVal::Contains(const IPAddr& addr) const
{ {
IPAddr a(addr); return val.subnet_val->Contains(addr);
return val.subnet_val->Contains(a);
} }
Val* SubNetVal::DoClone(CloneState* state) Val* SubNetVal::DoClone(CloneState* state)

View file

@ -176,7 +176,7 @@ bool Config::DoUpdate()
// keep a list of options to remove because they were no longer in the input file. // keep a list of options to remove because they were no longer in the input file.
// Start out with all element and removes while going along // Start out with all element and removes while going along
std::unordered_set<std::string> unseen_options; std::unordered_set<std::string> unseen_options;
for ( auto i : option_values ) for ( const auto& i : option_values )
{ {
unseen_options.insert(i.first); unseen_options.insert(i.first);
} }
@ -282,7 +282,7 @@ bool Config::DoUpdate()
EndCurrentSend(); EndCurrentSend();
// clean up all options we did not see // clean up all options we did not see
for ( auto i : unseen_options ) for ( const auto& i : unseen_options )
option_values.erase(i); option_values.erase(i);
return true; return true;

View file

@ -173,7 +173,7 @@ bool CardinalityCounter::Merge(CardinalityCounter* c)
if ( m != c->GetM() ) if ( m != c->GetM() )
return false; return false;
const vector<uint8_t> temp = c->GetBuckets(); const vector<uint8_t>& temp = c->GetBuckets();
V = 0; V = 0;

View file

@ -23,7 +23,7 @@ using namespace zeekygen;
static void write_plugin_section_heading(FILE* f, const plugin::Plugin* p) static void write_plugin_section_heading(FILE* f, const plugin::Plugin* p)
{ {
string name = p->Name(); const string& name = p->Name();
fprintf(f, "%s\n", name.c_str()); fprintf(f, "%s\n", name.c_str());
for ( size_t i = 0; i < name.size(); ++i ) for ( size_t i = 0; i < name.size(); ++i )