From da6fd3e3abd0b6f4eee7cadd5d9282d55a1efc2e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 14 Sep 2019 16:29:27 -0700 Subject: [PATCH] ircd::http: Move version mismatch to unlikely segment. ircd::m::vm: Reduce branches. ircd::http: Minor cleanup. --- ircd/http.cc | 9 +++++++-- modules/m_vm.cc | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ircd/http.cc b/ircd/http.cc index f0cd5a330..c5b10156c 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -292,7 +292,7 @@ ircd::http::request::head::head(parse::capstan &pc, this->version == "HTTP/1.1" }; - if(!version_compatible) + if(unlikely(!version_compatible)) throw error { HTTP_VERSION_NOT_SUPPORTED, fmt::snstringf @@ -302,7 +302,7 @@ ircd::http::request::head::head(parse::capstan &pc, } }; - return http::headers{pc, [this, &c](const auto &h) + const auto each_header{[this, &c](const auto &h) { if(iequals(h.first, "host"_sv)) this->host = h.second; @@ -340,6 +340,11 @@ ircd::http::request::head::head(parse::capstan &pc, if(c) c(h); }}; + + return http::headers + { + pc, each_header + }; }()} { } diff --git a/modules/m_vm.cc b/modules/m_vm.cc index e1130616b..560ca5698 100644 --- a/modules/m_vm.cc +++ b/modules/m_vm.cc @@ -832,10 +832,10 @@ enum ircd::m::vm::fault ircd::m::vm::execute_edu(eval &eval, const event &event) { - if(eval.opts->eval) + if(likely(eval.opts->eval)) call_hook(eval_hook, eval, event, eval); - if(eval.opts->post) + if(likely(eval.opts->post)) call_hook(post_hook, eval, event, eval); return fault::ACCEPT; @@ -889,7 +889,7 @@ ircd::m::vm::execute_pdu(eval &eval, call_hook(conform_hook, eval, event, eval); } - if(eval::count(event_id) > 1) + if(unlikely(eval::count(event_id) > 1)) throw error { fault::EXISTS, "Event is already being evaluated."