From b3ea9223e7145214eb8560b6563476d0ebbec5ea Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Mon, 4 Oct 2021 12:16:56 -0700 Subject: [PATCH] Small optimization in SteamNetworkingMessagesSession::CheckConnection Move check to see if we are idle to be inside the (rarely true) if() branch where we use it. This could become a bit more important in the future if SNP_BHasAnyBufferedRecvData() becomes more expensive when lanes are added. P4:6806855 --- .../clientlib/csteamnetworkingmessages.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/steamnetworkingsockets/clientlib/csteamnetworkingmessages.cpp b/src/steamnetworkingsockets/clientlib/csteamnetworkingmessages.cpp index a75cc0e..ba1d6f6 100644 --- a/src/steamnetworkingsockets/clientlib/csteamnetworkingmessages.cpp +++ b/src/steamnetworkingsockets/clientlib/csteamnetworkingmessages.cpp @@ -800,9 +800,6 @@ void SteamNetworkingMessagesSession::CheckConnection( SteamNetworkingMicrosecond UpdateConnectionInfo(); - bool bIdle = !m_pConnection->SNP_BHasAnyBufferedRecvData() - && !m_pConnection->SNP_BHasAnyUnackedSentReliableData(); - // Safety check in case the connection got nuked without going thorugh an expected terminal state if ( !m_pConnection->BStateIsActive() ) { @@ -818,6 +815,9 @@ void SteamNetworkingMessagesSession::CheckConnection( SteamNetworkingMicrosecond // Check if the connection died if ( m_lastConnectionInfo.m_eState == k_ESteamNetworkingConnectionState_ProblemDetectedLocally || m_lastConnectionInfo.m_eState == k_ESteamNetworkingConnectionState_ClosedByPeer ) { + bool bIdle = !m_pConnection->SNP_BHasAnyBufferedRecvData() + && !m_pConnection->SNP_BHasAnyUnackedSentReliableData(); + SpewVerbose( "[%s] messages session %s: %d %s\n", m_lastConnectionInfo.m_szConnectionDescription, m_lastConnectionInfo.m_eState == k_ESteamNetworkingConnectionState_ProblemDetectedLocally ? "problem detected locally" : "closed by peer",