Avoid repeatedly calling stream->lowest_layer() within the same scope & move some variable constructions

This commit is contained in:
Yonas Habteab 2022-08-26 16:32:39 +02:00
parent e074e892ce
commit 52b1b7ead3
2 changed files with 6 additions and 8 deletions

View File

@ -92,11 +92,12 @@ void HttpServerConnection::Disconnect()
m_CheckLivenessTimer.cancel(); m_CheckLivenessTimer.cancel();
m_Stream->lowest_layer().cancel(ec); auto& lowestLayer = m_Stream->lowest_layer();
lowestLayer.cancel(ec);
m_Stream->next_layer().async_shutdown(yc[ec]); m_Stream->next_layer().async_shutdown(yc[ec]);
m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec); lowestLayer.shutdown(lowestLayer.shutdown_both, ec);
auto listener (ApiListener::GetInstance()); auto listener (ApiListener::GetInstance());
@ -239,8 +240,6 @@ bool HandleAccessControl(
auto headerAllowOrigin (listener->GetAccessControlAllowOrigin()); auto headerAllowOrigin (listener->GetAccessControlAllowOrigin());
if (headerAllowOrigin) { if (headerAllowOrigin) {
CpuBoundWork allowOriginHeader (yc);
auto allowedOrigins (headerAllowOrigin->ToSet<String>()); auto allowedOrigins (headerAllowOrigin->ToSet<String>());
if (!allowedOrigins.empty()) { if (!allowedOrigins.empty()) {
@ -250,8 +249,6 @@ bool HandleAccessControl(
response.set(http::field::access_control_allow_origin, origin); response.set(http::field::access_control_allow_origin, origin);
} }
allowOriginHeader.Done();
response.set(http::field::access_control_allow_credentials, "true"); response.set(http::field::access_control_allow_credentials, "true");
if (request.method() == http::verb::options && !request[http::field::access_control_request_method].empty()) { if (request.method() == http::verb::options && !request[http::field::access_control_request_method].empty()) {

View File

@ -226,7 +226,8 @@ void JsonRpcConnection::Disconnect()
m_CheckLivenessTimer.cancel(); m_CheckLivenessTimer.cancel();
m_HeartbeatTimer.cancel(); m_HeartbeatTimer.cancel();
m_Stream->lowest_layer().cancel(ec); auto& lowestLayer = m_Stream->lowest_layer();
lowestLayer.cancel(ec);
Timeout::Ptr shutdownTimeout (new Timeout( Timeout::Ptr shutdownTimeout (new Timeout(
m_IoStrand.context(), m_IoStrand.context(),
@ -242,7 +243,7 @@ void JsonRpcConnection::Disconnect()
shutdownTimeout->Cancel(); shutdownTimeout->Cancel();
m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec); lowestLayer.shutdown(lowestLayer.shutdown_both, ec);
} }
}); });
} }