From 6661c04a748860bc6f098ff62b01d3db515c0704 Mon Sep 17 00:00:00 2001 From: Max Plekh Date: Fri, 30 May 2025 17:40:20 +0300 Subject: [PATCH] mesh: cleaner struct init in HwmpRtable::AddReactivePath() Initialize ReactiveRoute struct before inserting into m_routes map to avoid unnecessary search. --- src/mesh/model/dot11s/hwmp-rtable.cc | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/mesh/model/dot11s/hwmp-rtable.cc b/src/mesh/model/dot11s/hwmp-rtable.cc index 93d6a5363..c2f5a36b0 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.cc +++ b/src/mesh/model/dot11s/hwmp-rtable.cc @@ -59,19 +59,12 @@ HwmpRtable::AddReactivePath(Mac48Address destination, { NS_LOG_FUNCTION(this << destination << retransmitter << interface << metric << lifetime.GetSeconds() << seqnum); - auto i = m_routes.find(destination); - if (i == m_routes.end()) - { - ReactiveRoute newroute; - m_routes[destination] = newroute; - } - i = m_routes.find(destination); - NS_ASSERT(i != m_routes.end()); - i->second.retransmitter = retransmitter; - i->second.interface = interface; - i->second.metric = metric; - i->second.whenExpire = Simulator::Now() + lifetime; - i->second.seqnum = seqnum; + auto& route = m_routes[destination]; // find existing record or create new + route.retransmitter = retransmitter; + route.interface = interface; + route.metric = metric; + route.whenExpire = Simulator::Now() + lifetime; + route.seqnum = seqnum; } void