1
0

Do an early check for empty network buffers (#5172)

Avoid overhead when nothing to do.
This commit is contained in:
Tiger Wang 2021-03-29 23:36:00 +01:00 committed by GitHub
parent abcc14076c
commit 8ec5552998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -232,6 +232,13 @@ void cClientHandle::ProcessProtocolOut()
decltype(m_OutgoingData) OutgoingData;
{
cCSLock Lock(m_CSOutgoingData);
// Bail out when there's nothing to send to avoid TCPLink::Send overhead:
if (m_OutgoingData.empty())
{
return;
}
std::swap(OutgoingData, m_OutgoingData);
}
@ -3318,12 +3325,14 @@ void cClientHandle::ProcessProtocolIn(void)
decltype(m_IncomingData) IncomingData;
{
cCSLock Lock(m_CSIncomingData);
std::swap(IncomingData, m_IncomingData);
}
if (IncomingData.empty())
{
return;
// Bail out when nothing was received:
if (m_IncomingData.empty())
{
return;
}
std::swap(IncomingData, m_IncomingData);
}
try