Scope: convert Scope::Lookup() and others to template

Allows passing rvalue references which eliminates unnecessary
std::string copies.

This speeds up Zeek startup by 1-2%.
This commit is contained in:
Max Kellermann 2020-02-04 11:53:33 +01:00
parent f8e9cc0fc5
commit f1908b6212
2 changed files with 13 additions and 7 deletions

View file

@ -177,11 +177,11 @@ ID* install_ID(const char* name, const char* module_name,
ID* id = new ID(full_name.data(), scope, is_export);
if ( SCOPE_FUNCTION != scope )
global_scope()->Insert(full_name, id);
global_scope()->Insert(std::move(full_name), id);
else
{
id->SetOffset(top_scope->Length());
top_scope->Insert(full_name, id);
top_scope->Insert(std::move(full_name), id);
}
return id;