Use emplace_back over push_back where appropriate

This commit is contained in:
Tim Wojtulewicz 2023-07-06 15:53:13 -07:00
parent 0d78eb1933
commit 64b78f6fb9
28 changed files with 86 additions and 86 deletions

View file

@ -63,7 +63,7 @@ DNS_Mapping::DNS_Mapping(FILE* f)
else else
req_addr = IPAddr(req_buf); req_addr = IPAddr(req_buf);
names.push_back(name_buf); names.emplace_back(name_buf);
for ( int i = 0; i < num_addrs; ++i ) for ( int i = 0; i < num_addrs; ++i )
{ {
@ -74,7 +74,7 @@ DNS_Mapping::DNS_Mapping(FILE* f)
if ( newline ) if ( newline )
*newline = '\0'; *newline = '\0';
addrs.emplace_back(IPAddr(buf)); addrs.emplace_back(buf);
} }
init_failed = false; init_failed = false;
@ -134,16 +134,16 @@ void DNS_Mapping::Init(struct hostent* h)
if ( h->h_name ) if ( h->h_name )
// for now, just use the official name // for now, just use the official name
// TODO: this could easily be expanded to include all of the aliases as well // TODO: this could easily be expanded to include all of the aliases as well
names.push_back(h->h_name); names.emplace_back(h->h_name);
if ( h->h_addr_list ) if ( h->h_addr_list )
{ {
for ( int i = 0; h->h_addr_list[i] != NULL; ++i ) for ( int i = 0; h->h_addr_list[i] != NULL; ++i )
{ {
if ( h->h_addrtype == AF_INET ) if ( h->h_addrtype == AF_INET )
addrs.push_back(IPAddr(IPv4, (uint32_t*)h->h_addr_list[i], IPAddr::Network)); addrs.emplace_back(IPv4, (uint32_t*)h->h_addr_list[i], IPAddr::Network);
else if ( h->h_addrtype == AF_INET6 ) else if ( h->h_addrtype == AF_INET6 )
addrs.push_back(IPAddr(IPv6, (uint32_t*)h->h_addr_list[i], IPAddr::Network)); addrs.emplace_back(IPv6, (uint32_t*)h->h_addr_list[i], IPAddr::Network);
} }
} }

View file

@ -342,7 +342,7 @@ static void parse_function_name(vector<ParseLocationRec>& result, ParseLocationR
vector<ParseLocationRec> parse_location_string(const string& s) vector<ParseLocationRec> parse_location_string(const string& s)
{ {
vector<ParseLocationRec> result; vector<ParseLocationRec> result;
result.push_back(ParseLocationRec()); result.emplace_back();
ParseLocationRec& plr = result[0]; ParseLocationRec& plr = result[0];
// If PLR_FILE_AND_LINE, set this to the filename you want; for // If PLR_FILE_AND_LINE, set this to the filename you want; for
@ -531,7 +531,7 @@ void tokenize(const char* cstr, string& operation, vector<string>& arguments)
if ( ! num_tokens ) if ( ! num_tokens )
operation = string(str, start, len); operation = string(str, start, len);
else else
arguments.push_back(string(str, start, len)); arguments.emplace_back(str, start, len);
++num_tokens; ++num_tokens;
} }

View file

@ -388,10 +388,10 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
vector<ID*> choices; vector<ID*> choices;
choose_global_symbols_regex(args[0], choices, true); choose_global_symbols_regex(args[0], choices, true);
for ( unsigned int i = 0; i < choices.size(); ++i ) for ( unsigned int i = 0; i < choices.size(); ++i )
locstrings.push_back(choices[i]->Name()); locstrings.emplace_back(choices[i]->Name());
} }
else else
locstrings.push_back(args[0].c_str()); locstrings.push_back(args[0]);
for ( unsigned int strindex = 0; strindex < locstrings.size(); ++strindex ) for ( unsigned int strindex = 0; strindex < locstrings.size(); ++strindex )
{ {

View file

@ -148,7 +148,7 @@ bool File::Open(FILE* file, const char* mode)
} }
is_open = true; is_open = true;
open_files.emplace_back(std::make_pair(name, this)); open_files.emplace_back(name, this);
RaiseOpenEvent(); RaiseOpenEvent();

View file

@ -79,7 +79,7 @@ std::list<std::tuple<IPPrefix, void*>> PrefixTable::FindAll(const IPAddr& addr,
patricia_search_all(tree, prefix, &list, &elems); patricia_search_all(tree, prefix, &list, &elems);
for ( int i = 0; i < elems; ++i ) for ( int i = 0; i < elems; ++i )
out.push_back(std::make_tuple(PrefixToIPPrefix(list[i]->prefix), list[i]->data)); out.emplace_back(PrefixToIPPrefix(list[i]->prefix), list[i]->data);
Deref_Prefix(prefix); Deref_Prefix(prefix);
free(list); free(list);

View file

@ -24,12 +24,12 @@ void ScriptCoverageManager::AddStmt(Stmt* s)
if ( ignoring != 0 ) if ( ignoring != 0 )
return; return;
stmts.push_back({NewRef{}, s}); stmts.emplace_back(NewRef{}, s);
} }
void ScriptCoverageManager::AddFunction(IDPtr func_id, StmtPtr body) void ScriptCoverageManager::AddFunction(IDPtr func_id, StmtPtr body)
{ {
func_instances.push_back({func_id, body}); func_instances.emplace_back(func_id, body);
} }
bool ScriptCoverageManager::ReadStats() bool ScriptCoverageManager::ReadStats()

View file

@ -37,7 +37,7 @@ const Substring& Substring::operator=(const Substring& bst)
void Substring::AddAlignment(const String* str, int index) void Substring::AddAlignment(const String* str, int index)
{ {
_aligns.push_back(BSSAlign(str, index)); _aligns.emplace_back(str, index);
} }
bool Substring::DoesCover(const Substring* bst) const bool Substring::DoesCover(const Substring* bst) const

View file

@ -2085,7 +2085,7 @@ void WhenInfo::BuildProfile()
if ( ! is_present ) if ( ! is_present )
{ {
IDPtr wl_ptr = {NewRef{}, const_cast<ID*>(wl)}; IDPtr wl_ptr = {NewRef{}, const_cast<ID*>(wl)};
cl->emplace_back(FuncType::Capture{wl_ptr, false}); cl->emplace_back(wl_ptr, false);
} }
// In addition, don't treat them as external locals that // In addition, don't treat them as external locals that
@ -2098,7 +2098,7 @@ void WhenInfo::BuildProfile()
// We need IDPtr versions of the locals so we can manipulate // We need IDPtr versions of the locals so we can manipulate
// them during script optimization. // them during script optimization.
auto non_const_w = const_cast<ID*>(w); auto non_const_w = const_cast<ID*>(w);
when_expr_locals.push_back({NewRef{}, non_const_w}); when_expr_locals.emplace_back(NewRef{}, non_const_w);
} }
} }

View file

@ -398,7 +398,7 @@ void Trigger::Register(const ID* const_id)
notifier::detail::registry.Register(id, this); notifier::detail::registry.Register(id, this);
Ref(id); Ref(id);
objs.push_back({id, id}); objs.emplace_back(id, id);
} }
void Trigger::Register(Val* val) void Trigger::Register(Val* val)

View file

@ -1196,7 +1196,7 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td)
else else
{ {
auto efi = std::make_unique<detail::ExprFieldInit>(def_expr, type); auto efi = std::make_unique<detail::ExprFieldInit>(def_expr, type);
creation_inits.emplace_back(std::make_pair(field, std::move(efi))); creation_inits.emplace_back(field, std::move(efi));
} }
} }
@ -1793,7 +1793,7 @@ EnumType::enum_name_list EnumType::Names() const
{ {
enum_name_list n; enum_name_list n;
for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter ) for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter )
n.push_back(std::make_pair(iter->first, iter->second)); n.emplace_back(iter->first, iter->second);
return n; return n;
} }

View file

@ -1012,7 +1012,7 @@ StringValPtr StringVal::Replace(RE_Matcher* re, const String& repl, bool do_all)
break; break;
// s[offset .. offset+end_of_match-1] matches re. // s[offset .. offset+end_of_match-1] matches re.
cut_points.push_back({offset, offset + end_of_match}); cut_points.emplace_back(offset, offset + end_of_match);
offset += end_of_match; offset += end_of_match;
n -= end_of_match; n -= end_of_match;

View file

@ -222,7 +222,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line)
// Some clients pipeline their commands (i.e., keep sending // Some clients pipeline their commands (i.e., keep sending
// without waiting for a server's responses). Therefore we // without waiting for a server's responses). Therefore we
// keep a list of pending commands. // keep a list of pending commands.
cmds.push_back(std::string(line)); cmds.emplace_back(line);
if ( cmds.size() == 1 ) if ( cmds.size() == 1 )
// Not waiting for another server response, // Not waiting for another server response,

View file

@ -71,7 +71,7 @@ refine flow SIP_Flow += {
if ( build_headers ) if ( build_headers )
{ {
headers.push_back({zeek::AdoptRef{}, build_sip_header_val(name, value)}); headers.emplace_back(zeek::AdoptRef{}, build_sip_header_val(name, value));
} }
return true; return true;

View file

@ -889,7 +889,7 @@ broker::expected<broker::data> val_to_data(const Val* v)
std::string name(f->Name()); std::string name(f->Name());
broker::vector rval; broker::vector rval;
rval.push_back(name); rval.emplace_back(name);
if ( name.find("lambda_<") == 0 ) if ( name.find("lambda_<") == 0 )
{ {

View file

@ -23,7 +23,7 @@ bool None::DoInit(const WriterInfo& info, int num_fields, const threading::Field
for ( WriterInfo::config_map::const_iterator i = info.config.begin(); for ( WriterInfo::config_map::const_iterator i = info.config.begin();
i != info.config.end(); i++ ) i != info.config.end(); i++ )
keys.push_back(std::make_pair(i->first, i->second)); keys.emplace_back(i->first, i->second);
std::sort(keys.begin(), keys.end()); std::sort(keys.begin(), keys.end());

View file

@ -189,7 +189,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
return true; return true;
} }
errors->push_back(util::fmt("plugin %s is not available", name.c_str())); errors->emplace_back(util::fmt("plugin %s is not available", name.c_str()));
return false; return false;
} }
@ -216,7 +216,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
"dynamic plugin %s from directory %s conflicts with %s plugin %s (%d.%d.%d)", "dynamic plugin %s from directory %s conflicts with %s plugin %s (%d.%d.%d)",
name.c_str(), dir.c_str(), p->DynamicPlugin() ? "dynamic" : "built-in", name.c_str(), dir.c_str(), p->DynamicPlugin() ? "dynamic" : "built-in",
p->Name().c_str(), v.major, v.minor, v.patch); p->Name().c_str(), v.major, v.minor, v.patch);
errors->push_back(error); errors->emplace_back(error);
return false; return false;
} }
} }
@ -245,14 +245,14 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
if ( ! hdl ) if ( ! hdl )
{ {
const char* err = dlerror(); const char* err = dlerror();
errors->push_back(util::fmt("cannot load plugin library %s: %s", path, errors->emplace_back(util::fmt("cannot load plugin library %s: %s", path,
err ? err : "<unknown error>")); err ? err : "<unknown error>"));
continue; continue;
} }
if ( ! current_plugin ) if ( ! current_plugin )
{ {
errors->push_back( errors->emplace_back(
util::fmt("load plugin library %s did not instantiate a plugin", path)); util::fmt("load plugin library %s did not instantiate a plugin", path));
dlclose(hdl); dlclose(hdl);
continue; continue;
@ -275,7 +275,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
// what we expect from its magic file. // what we expect from its magic file.
if ( util::strtolower(current_plugin->Name()) != util::strtolower(name) ) if ( util::strtolower(current_plugin->Name()) != util::strtolower(name) )
{ {
errors->push_back(util::fmt("inconsistent plugin name: %s vs %s", errors->emplace_back(util::fmt("inconsistent plugin name: %s vs %s",
current_plugin->Name().c_str(), name.c_str())); current_plugin->Name().c_str(), name.c_str()));
continue; continue;
} }
@ -577,7 +577,7 @@ Manager::inactive_plugin_list Manager::InactivePlugins() const
} }
if ( ! found ) if ( ! found )
inactives.push_back(*i); inactives.emplace_back(*i);
} }
return inactives; return inactives;
@ -646,7 +646,7 @@ std::list<std::pair<HookType, int>> Manager::HooksEnabledForPlugin(const Plugin*
if ( hook_list* l = hooks[i] ) if ( hook_list* l = hooks[i] )
for ( const auto& [hook, hook_plugin] : *l ) for ( const auto& [hook, hook_plugin] : *l )
if ( hook_plugin == plugin ) if ( hook_plugin == plugin )
enabled.push_back(std::make_pair(static_cast<HookType>(i), hook)); enabled.emplace_back(static_cast<HookType>(i), hook);
} }
return enabled; return enabled;
@ -666,7 +666,7 @@ void Manager::EnableHook(HookType hook, Plugin* plugin, int prio)
return; return;
} }
l->push_back(std::make_pair(prio, plugin)); l->emplace_back(prio, plugin);
l->sort(hook_cmp); l->sort(hook_cmp);
} }
@ -710,9 +710,9 @@ int Manager::HookLoadFile(const Plugin::LoadType type, const string& file, const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(type)); args.emplace_back(type);
args.push_back(HookArgument(file)); args.emplace_back(file);
args.push_back(HookArgument(resolved)); args.emplace_back(resolved);
MetaHookPre(HOOK_LOAD_FILE, args); MetaHookPre(HOOK_LOAD_FILE, args);
} }
@ -745,9 +745,9 @@ Manager::HookLoadFileExtended(const Plugin::LoadType type, const string& file,
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(type)); args.emplace_back(type);
args.push_back(HookArgument(file)); args.emplace_back(file);
args.push_back(HookArgument(resolved)); args.emplace_back(resolved);
MetaHookPre(HOOK_LOAD_FILE_EXT, args); MetaHookPre(HOOK_LOAD_FILE_EXT, args);
} }
@ -785,9 +785,9 @@ std::pair<bool, ValPtr> Manager::HookCallFunction(const Func* func, zeek::detail
for ( const auto& v : *vecargs ) for ( const auto& v : *vecargs )
vargs.push_back(v.get()); vargs.push_back(v.get());
args.push_back(HookArgument(func)); args.emplace_back(func);
args.push_back(HookArgument(parent)); args.emplace_back(parent);
args.push_back(HookArgument(&vargs)); args.emplace_back(&vargs);
MetaHookPre(HOOK_CALL_FUNCTION, args); MetaHookPre(HOOK_CALL_FUNCTION, args);
} }
@ -821,7 +821,7 @@ bool Manager::HookQueueEvent(Event* event) const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(event)); args.emplace_back(event);
MetaHookPre(HOOK_QUEUE_EVENT, args); MetaHookPre(HOOK_QUEUE_EVENT, args);
} }
@ -873,7 +873,7 @@ void Manager::HookSetupAnalyzerTree(Connection* conn) const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(conn)); args.emplace_back(conn);
MetaHookPre(HOOK_SETUP_ANALYZER_TREE, args); MetaHookPre(HOOK_SETUP_ANALYZER_TREE, args);
} }
@ -900,7 +900,7 @@ void Manager::HookUpdateNetworkTime(double network_time) const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(network_time)); args.emplace_back(network_time);
MetaHookPre(HOOK_UPDATE_NETWORK_TIME, args); MetaHookPre(HOOK_UPDATE_NETWORK_TIME, args);
} }
@ -923,7 +923,7 @@ void Manager::HookObjDtor(void* obj) const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(obj)); args.emplace_back(obj);
MetaHookPre(HOOK_OBJ_DTOR, args); MetaHookPre(HOOK_OBJ_DTOR, args);
} }
@ -948,13 +948,13 @@ void Manager::HookLogInit(const std::string& writer, const std::string& instanti
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(writer)); args.emplace_back(writer);
args.push_back(HookArgument(instantiating_filter)); args.emplace_back(instantiating_filter);
args.push_back(HookArgument(local)); args.emplace_back(local);
args.push_back(HookArgument(remote)); args.emplace_back(remote);
args.push_back(HookArgument(&info)); args.emplace_back(&info);
args.push_back(HookArgument(num_fields)); args.emplace_back(num_fields);
args.push_back(HookArgument(std::make_pair(num_fields, fields))); args.emplace_back(std::make_pair(num_fields, fields));
MetaHookPre(HOOK_LOG_INIT, args); MetaHookPre(HOOK_LOG_INIT, args);
} }
@ -979,12 +979,12 @@ bool Manager::HookLogWrite(const std::string& writer, const std::string& filter,
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(writer)); args.emplace_back(writer);
args.push_back(HookArgument(filter)); args.emplace_back(filter);
args.push_back(HookArgument(&info)); args.emplace_back(&info);
args.push_back(HookArgument(num_fields)); args.emplace_back(num_fields);
args.push_back(HookArgument(std::make_pair(num_fields, fields))); args.emplace_back(std::make_pair(num_fields, fields));
args.push_back(HookArgument(vals)); args.emplace_back(vals);
MetaHookPre(HOOK_LOG_WRITE, args); MetaHookPre(HOOK_LOG_WRITE, args);
} }
@ -1021,14 +1021,14 @@ bool Manager::HookReporter(const std::string& prefix, const EventHandlerPtr even
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.push_back(HookArgument(prefix)); args.emplace_back(prefix);
args.push_back(HookArgument(conn)); args.emplace_back(conn);
args.push_back(HookArgument(addl)); args.emplace_back(addl);
args.push_back(HookArgument(location1)); args.emplace_back(location1);
args.push_back(HookArgument(location2)); args.emplace_back(location2);
args.push_back(HookArgument(location)); args.emplace_back(location);
args.push_back(HookArgument(time)); args.emplace_back(time);
args.push_back(HookArgument(message)); args.emplace_back(message);
MetaHookPre(HOOK_REPORTER, args); MetaHookPre(HOOK_REPORTER, args);
} }
@ -1063,7 +1063,7 @@ void Manager::HookUnprocessedPacket(const Packet* packet) const
if ( HavePluginForHook(META_HOOK_PRE) ) if ( HavePluginForHook(META_HOOK_PRE) )
{ {
args.emplace_back(HookArgument{packet}); args.emplace_back(packet);
MetaHookPre(HOOK_UNPROCESSED_PACKET, args); MetaHookPre(HOOK_UNPROCESSED_PACKET, args);
} }

View file

@ -119,7 +119,7 @@ DefaultHasher::DefaultHasher(size_t k, Hasher::seed_t seed) : Hasher(k, seed)
{ {
seed_t s = Seed(); seed_t s = Seed();
s.h[0] += util::detail::prng(i); s.h[0] += util::detail::prng(i);
hash_functions.push_back(UHF(s)); hash_functions.emplace_back(s);
} }
} }

View file

@ -156,7 +156,7 @@ shared_ptr<CPP_InitInfo> CPPCompile::RegisterConstant(const ValPtr& vp, int& con
const_vals[v] = constants[c_desc] = gi; const_vals[v] = constants[c_desc] = gi;
consts_offset = const_offsets[v] = constants_offsets[c_desc] = consts.size(); consts_offset = const_offsets[v] = constants_offsets[c_desc] = consts.size();
consts.emplace_back(pair(tag, gi->Offset())); consts.emplace_back(tag, gi->Offset());
return gi; return gi;
} }

View file

@ -1352,7 +1352,7 @@ string CPPCompile::GenField(const ExprPtr& rec, int field)
ASSERT(pt != processed_types.end()); ASSERT(pt != processed_types.end());
auto rt_offset = pt->second->Offset(); auto rt_offset = pt->second->Offset();
string field_name = rt->FieldName(field); string field_name = rt->FieldName(field);
field_decls.emplace_back(pair(rt_offset, rt->FieldDecl(field))); field_decls.emplace_back(rt_offset, rt->FieldDecl(field));
if ( rfm != record_field_mappings.end() ) if ( rfm != record_field_mappings.end() )
// We're already tracking this record. // We're already tracking this record.
@ -1392,7 +1392,7 @@ string CPPCompile::GenEnum(const TypePtr& t, const ValPtr& ev)
mapping_slot = num_ev_mappings++; mapping_slot = num_ev_mappings++;
string enum_name = et->Lookup(v); string enum_name = et->Lookup(v);
enum_names.emplace_back(pair(TypeOffset(t), std::move(enum_name))); enum_names.emplace_back(TypeOffset(t), std::move(enum_name));
if ( evm != enum_val_mappings.end() ) if ( evm != enum_val_mappings.end() )
{ {

View file

@ -208,7 +208,7 @@ FuncValPtr lookup_func__CPP(string name, int num_bodies, vector<p_hash_type> has
ASSERT(cs != compiled_scripts.end()); ASSERT(cs != compiled_scripts.end());
const auto& f = cs->second; const auto& f = cs->second;
bodies.push_back(f.body); bodies.emplace_back(f.body);
priorities.push_back(f.priority); priorities.push_back(f.priority);
// This might register the same event more than once, // This might register the same event more than once,

View file

@ -26,7 +26,7 @@ void GenIDDefs::TraverseFunction(const Func* f, ScopePtr scope, StmtPtr body)
// Establish the outermost barrier and associated set of // Establish the outermost barrier and associated set of
// identifiers. // identifiers.
barrier_blocks.push_back(0); barrier_blocks.push_back(0);
modified_IDs.push_back({}); modified_IDs.emplace_back();
for ( const auto& g : pf->Globals() ) for ( const auto& g : pf->Globals() )
{ {
@ -434,7 +434,7 @@ void GenIDDefs::StartConfluenceBlock(const Stmt* s)
barrier_blocks.push_back(confluence_blocks.size()); barrier_blocks.push_back(confluence_blocks.size());
confluence_blocks.push_back(s); confluence_blocks.push_back(s);
modified_IDs.push_back({}); modified_IDs.emplace_back();
} }
void GenIDDefs::EndConfluenceBlock(bool no_orig) void GenIDDefs::EndConfluenceBlock(bool no_orig)

View file

@ -77,7 +77,7 @@ void IDOptInfo::AddInitExpr(ExprPtr init_expr, InitClass ic)
return; return;
if ( my_id->IsGlobal() ) if ( my_id->IsGlobal() )
global_init_exprs.emplace_back(IDInitInfo(my_id, init_expr, ic)); global_init_exprs.emplace_back(my_id, init_expr, ic);
init_exprs.emplace_back(std::move(init_expr)); init_exprs.emplace_back(std::move(init_expr));
} }

View file

@ -92,7 +92,7 @@ void add_func_analysis_pattern(AnalyOpt& opts, const char* pat)
try try
{ {
std::string full_pat = std::string("^(") + pat + ")$"; std::string full_pat = std::string("^(") + pat + ")$";
opts.only_funcs.emplace_back(std::regex(full_pat)); opts.only_funcs.emplace_back(full_pat);
} }
catch ( const std::regex_error& e ) catch ( const std::regex_error& e )
{ {
@ -105,7 +105,7 @@ void add_file_analysis_pattern(AnalyOpt& opts, const char* pat)
try try
{ {
std::string full_pat = std::string("^.*(") + pat + ").*$"; std::string full_pat = std::string("^.*(") + pat + ").*$";
opts.only_files.emplace_back(std::regex(full_pat)); opts.only_files.emplace_back(full_pat);
} }
catch ( const std::regex_error& e ) catch ( const std::regex_error& e )
{ {

View file

@ -11,7 +11,7 @@ namespace zeek::detail
void ZAMCompiler::PushGoTos(GoToSets& gotos) void ZAMCompiler::PushGoTos(GoToSets& gotos)
{ {
gotos.push_back({}); gotos.emplace_back();
} }
void ZAMCompiler::ResolveGoTos(GoToSets& gotos, const InstLabel l) void ZAMCompiler::ResolveGoTos(GoToSets& gotos, const InstLabel l)

View file

@ -837,7 +837,7 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
aux->value_var_type = value_var->GetType(); aux->value_var_type = value_var->GetType();
auto iter_slot = table_iters.size(); auto iter_slot = table_iters.size();
table_iters.emplace_back(TableIterInfo()); table_iters.emplace_back();
auto z = ZInstI(OP_INIT_TABLE_LOOP_VV, FrameSlot(val), iter_slot); auto z = ZInstI(OP_INIT_TABLE_LOOP_VV, FrameSlot(val), iter_slot);
z.op_type = OP_VV_I2; z.op_type = OP_VV_I2;

View file

@ -277,7 +277,7 @@ const threading::Manager::msg_stats_list& threading::Manager::GetMsgThreadStats(
MsgThread::Stats s; MsgThread::Stats s;
t->GetStats(&s); t->GetStats(&s);
stats.push_back(std::make_pair(t->Name(), s)); stats.emplace_back(t->Name(), s);
} }
return stats; return stats;

View file

@ -51,11 +51,11 @@ static void add_summary_rows(const ODesc& id_desc, const vector<string>& cmnts,
ReStructuredTextTable* table) ReStructuredTextTable* table)
{ {
vector<string> row; vector<string> row;
row.push_back(id_desc.Description()); row.emplace_back(id_desc.Description());
if ( cmnts.empty() ) if ( cmnts.empty() )
{ {
row.push_back(""); row.emplace_back();
table->AddRow(row); table->AddRow(row);
return; return;
} }
@ -66,7 +66,7 @@ static void add_summary_rows(const ODesc& id_desc, const vector<string>& cmnts,
for ( size_t i = 1; i < cmnts.size(); ++i ) for ( size_t i = 1; i < cmnts.size(); ++i )
{ {
row.clear(); row.clear();
row.push_back(""); row.emplace_back();
row.push_back(cmnts[i]); row.push_back(cmnts[i]);
table->AddRow(row); table->AddRow(row);
} }

View file

@ -505,7 +505,7 @@ vector<string> dir_contents_recursive(string dir)
while ( (n = fts_read(fts)) ) while ( (n = fts_read(fts)) )
{ {
if ( n->fts_info & FTS_F ) if ( n->fts_info & FTS_F )
rval.push_back(n->fts_path); rval.emplace_back(n->fts_path);
} }
if ( errno ) if ( errno )