mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Prevent unnecessary copies in Spicy bindings
This commit is contained in:
parent
7f1d3ae559
commit
a4ab0af70d
6 changed files with 17 additions and 17 deletions
|
@ -244,7 +244,7 @@ void Manager::registerType(const std::string& id, const TypePtr& type) {
|
|||
zeek_id->SetType(type);
|
||||
zeek_id->MakeType();
|
||||
|
||||
detail::zeekygen_mgr->Identifier(zeek_id);
|
||||
detail::zeekygen_mgr->Identifier(std::move(zeek_id));
|
||||
|
||||
if ( _module_info )
|
||||
_module_info->AddBifItem(id, ::zeek::plugin::BifItem::TYPE);
|
||||
|
@ -281,7 +281,7 @@ void Manager::registerEvent(const std::string& name) {
|
|||
if ( auto id = detail::lookup_ID(name.c_str(), mod.c_str(), false, false, false) ) {
|
||||
// Auto-export IDs that already exist.
|
||||
id->SetExport();
|
||||
_events[name] = id;
|
||||
_events[name] = std::move(id);
|
||||
}
|
||||
else
|
||||
// This installs & exports the ID, but it doesn't set its type yet.
|
||||
|
@ -632,7 +632,7 @@ void Manager::InitPostScript() {
|
|||
hilti_config.abort_on_exceptions = id::find_const("Spicy::abort_on_exceptions")->AsBool();
|
||||
hilti_config.show_backtraces = id::find_const("Spicy::show_backtraces")->AsBool();
|
||||
|
||||
hilti::rt::configuration::set(hilti_config);
|
||||
hilti::rt::configuration::set(std::move(hilti_config));
|
||||
|
||||
auto spicy_config = ::spicy::rt::configuration::get();
|
||||
spicy_config.hook_accept_input = hook_accept_input;
|
||||
|
@ -686,7 +686,7 @@ void Manager::InitPostScript() {
|
|||
if ( ! tag )
|
||||
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
||||
|
||||
auto register_analyzer_for_port = [&](auto tag, const hilti::rt::Port& port_) {
|
||||
auto register_analyzer_for_port = [&](const auto& tag, const hilti::rt::Port& port_) {
|
||||
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for port %s", port_));
|
||||
|
||||
// Well-known ports are registered in scriptland, so we'll raise an
|
||||
|
@ -695,7 +695,7 @@ void Manager::InitPostScript() {
|
|||
vals.emplace_back(tag.AsVal());
|
||||
vals.emplace_back(zeek::spicy::rt::to_val(port_, base_type(TYPE_PORT)));
|
||||
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_port");
|
||||
event_mgr.Enqueue(handler, vals);
|
||||
event_mgr.Enqueue(handler, std::move(vals));
|
||||
};
|
||||
|
||||
for ( const auto& ports : p.ports ) {
|
||||
|
@ -717,7 +717,7 @@ void Manager::InitPostScript() {
|
|||
}
|
||||
|
||||
if ( p.parser_resp ) {
|
||||
for ( auto port : p.parser_resp->ports ) {
|
||||
for ( const auto& port : p.parser_resp->ports ) {
|
||||
if ( port.direction != ::spicy::rt::Direction::Both &&
|
||||
port.direction != ::spicy::rt::Direction::Responder )
|
||||
continue;
|
||||
|
@ -742,7 +742,7 @@ void Manager::InitPostScript() {
|
|||
if ( ! tag )
|
||||
reporter->InternalError("cannot get analyzer tag for '%s'", p.name_analyzer.c_str());
|
||||
|
||||
auto register_analyzer_for_mime_type = [&](auto tag, const std::string& mt) {
|
||||
auto register_analyzer_for_mime_type = [&](const auto& tag, const std::string& mt) {
|
||||
SPICY_DEBUG(hilti::rt::fmt(" Scheduling analyzer for MIME type %s", mt));
|
||||
|
||||
// MIME types are registered in scriptland, so we'll raise an
|
||||
|
@ -751,7 +751,7 @@ void Manager::InitPostScript() {
|
|||
vals.emplace_back(tag.AsVal());
|
||||
vals.emplace_back(make_intrusive<StringVal>(mt));
|
||||
EventHandlerPtr handler = event_registry->Register("spicy_analyzer_for_mime_type");
|
||||
event_mgr.Enqueue(handler, vals);
|
||||
event_mgr.Enqueue(handler, std::move(vals));
|
||||
};
|
||||
|
||||
for ( const auto& mt : p.mime_types )
|
||||
|
|
|
@ -120,7 +120,7 @@ TypePtr rt::create_enum_type(
|
|||
etype->AddName(ns, name.c_str(), lval, true);
|
||||
}
|
||||
|
||||
return etype;
|
||||
return std::move(etype);
|
||||
}
|
||||
|
||||
TypePtr rt::create_record_type(const std::string& ns, const std::string& id,
|
||||
|
@ -289,7 +289,7 @@ void rt::debug(const Cookie& cookie, const std::string& msg) {
|
|||
hilti::rt::fmt("[%s/%" PRIu32 "/%s] %s", name, p->analyzer->GetID(), (p->is_orig ? "orig" : "resp"), msg));
|
||||
}
|
||||
else if ( const auto f = cookie.file ) {
|
||||
auto name = file_mgr->GetComponentName(f->analyzer->Tag());
|
||||
const auto& name = file_mgr->GetComponentName(f->analyzer->Tag());
|
||||
SPICY_DEBUG(hilti::rt::fmt("[%s/%" PRIu32 "] %s", name, f->analyzer->GetID(), msg));
|
||||
}
|
||||
else if ( const auto f = cookie.packet ) {
|
||||
|
|
|
@ -705,7 +705,7 @@ inline ValPtr to_val(const hilti::rt::Vector<T>& v, const TypePtr& target) {
|
|||
for ( const auto& i : v )
|
||||
zv->Assign(zv->Size(), to_val(i, vt->Yield()));
|
||||
|
||||
return zv;
|
||||
return std::move(zv);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,5 +56,5 @@ function Spicy::__resource_usage%(%) : Spicy::ResourceUsage
|
|||
r->Assign(n++, ru.max_fiber_stack_size);
|
||||
r->Assign(n++, ru.cached_fibers);
|
||||
|
||||
return r;
|
||||
return std::move(r);
|
||||
%}
|
||||
|
|
|
@ -137,7 +137,7 @@ hilti::Result<hilti::Nothing> Driver::loadFile(hilti::rt::filesystem::path file,
|
|||
hilti::util::fmt("error computing path of %s relative to %s: %s", file, relative_to, ec.message()));
|
||||
|
||||
if ( exists )
|
||||
file = p;
|
||||
file = std::move(p);
|
||||
}
|
||||
|
||||
auto exists = hilti::rt::filesystem::exists(file, ec);
|
||||
|
|
|
@ -422,7 +422,7 @@ void GlueCompiler::preprocessEvtFile(hilti::rt::filesystem::path& path, std::ist
|
|||
// Output empty line to keep line numbers the same
|
||||
out << '\n';
|
||||
|
||||
auto m = hilti::util::split1(trimmed);
|
||||
auto m = hilti::util::split1(std::move(trimmed));
|
||||
|
||||
if ( auto rc = pp.processLine(m.first, m.second); ! rc )
|
||||
throw ParseError(rc.error());
|
||||
|
@ -517,7 +517,7 @@ bool GlueCompiler::loadEvtFile(hilti::rt::filesystem::path& path) {
|
|||
else
|
||||
SPICY_DEBUG(hilti::util::fmt(" Got module %s to import", module));
|
||||
|
||||
_imports.emplace_back(hilti::ID(module), std::move(scope));
|
||||
_imports.emplace_back(hilti::ID(std::move(module)), std::move(scope));
|
||||
}
|
||||
|
||||
else if ( looking_at(*chunk, 0, "export") ) {
|
||||
|
@ -699,7 +699,7 @@ glue::ProtocolAnalyzer GlueCompiler::parseProtocolAnalyzer(const std::string& ch
|
|||
|
||||
case both:
|
||||
a.unit_name_orig = unit;
|
||||
a.unit_name_resp = unit;
|
||||
a.unit_name_resp = std::move(unit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ bool GlueCompiler::CreateSpicyHook(glue::Event* ev) {
|
|||
#endif
|
||||
auto parameters = hilti::util::transform(ev->parameters, [](const auto& p) { return p.get(); });
|
||||
auto unit_hook = builder()->declarationHook(parameters, body.block(), attrs, meta);
|
||||
auto hook_decl = builder()->declarationUnitHook(ev->hook, unit_hook, meta);
|
||||
auto hook_decl = builder()->declarationUnitHook(ev->hook, unit_hook, std::move(meta));
|
||||
ev->spicy_module->spicy_module->add(context(), hook_decl);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue