From ec980edf56253d37c1bca94b317b733273aeb057 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 21 Jan 2015 15:13:46 -0500 Subject: [PATCH] don't look for tunnel again if tunnelID is the same as for previous message --- Tunnel.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index 5b672849..ed82e3e8 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -347,10 +347,16 @@ namespace tunnel try { I2NPMessage * msg = m_Queue.GetNextWithTimeout (1000); // 1 sec + uint32_t prevTunnelID = 0; + TunnelBase * prevTunnel = nullptr; while (msg) { - uint32_t tunnelID = bufbe32toh (msg->GetPayload ()); - TunnelBase * tunnel = GetInboundTunnel (tunnelID); + uint32_t tunnelID = bufbe32toh (msg->GetPayload ()); + TunnelBase * tunnel = nullptr; + if (tunnelID == prevTunnelID) + tunnel = prevTunnel; + if (!tunnel) + tunnel = GetInboundTunnel (tunnelID); if (!tunnel) tunnel = GetTransitTunnel (tunnelID); if (tunnel) @@ -362,6 +368,11 @@ namespace tunnel } msg = m_Queue.Get (); + if (msg) + { + prevTunnelID = tunnelID; + prevTunnel = tunnel; + } } uint64_t ts = i2p::util::GetSecondsSinceEpoch ();