Changed implementation from std::map to std::unordered_map of Val.cc

This commit is contained in:
Tomer Lev 2022-11-10 19:09:57 +02:00
parent d7474e2aa2
commit 9a3855cc38
2 changed files with 4 additions and 5 deletions

View file

@ -3972,11 +3972,10 @@ const PortValPtr& ValManager::Port(uint32_t port_num, TransportProto port_type)
port_num = 0; port_num = 0;
} }
std::pair key{port_num, port_type}; if ( ports.find(port_num) == ports.end() )
if ( ports.find(key) == ports.end() ) ports[port_num] = IntrusivePtr{AdoptRef{}, new PortVal(PortVal::Mask(port_num, port_type))};
ports[key] = IntrusivePtr{AdoptRef{}, new PortVal(PortVal::Mask(port_num, port_type))};
return ports[key]; return ports[port_num];
} }
const PortValPtr& ValManager::Port(uint32_t port_num) const PortValPtr& ValManager::Port(uint32_t port_num)

View file

@ -339,7 +339,7 @@ public:
const PortValPtr& Port(uint32_t port_num); const PortValPtr& Port(uint32_t port_num);
private: private:
std::map<std::pair<uint32_t, TransportProto>, PortValPtr> ports; std::unordered_map<uint32_t, PortValPtr> ports;
std::array<ValPtr, PREALLOCATED_COUNTS> counts; std::array<ValPtr, PREALLOCATED_COUNTS> counts;
std::array<ValPtr, PREALLOCATED_INTS> ints; std::array<ValPtr, PREALLOCATED_INTS> ints;
StringValPtr empty_string; StringValPtr empty_string;