0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::http: Move version mismatch to unlikely segment.

ircd:Ⓜ️:vm: Reduce branches.

ircd::http: Minor cleanup.
This commit is contained in:
Jason Volk 2019-09-14 16:29:27 -07:00
parent 9319df1a1b
commit da6fd3e3ab
2 changed files with 10 additions and 5 deletions

View file

@ -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
};
}()}
{
}

View file

@ -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."