switch map to unordered_map
Generally, unordered_maps should be preferred over map because they have
faster access times (O(1)) and tend to allocate less dynamic memory. We
do not rely on ordered iteration in any current use of maps, so it is
safe to do a full replace.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ieaa28ac7f70f9913d13d25142fea9861d49bb23f
diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp
index a390cbe..e1941cf 100644
--- a/fault-monitor/fru-fault-monitor.cpp
+++ b/fault-monitor/fru-fault-monitor.cpp
@@ -31,15 +31,16 @@
std::vector<std::tuple<std::string, std::string, std::string>>;
using Attributes = std::variant<bool, AssociationList>;
using PropertyName = std::string;
-using PropertyMap = std::map<PropertyName, Attributes>;
+using PropertyMap = std::unordered_map<PropertyName, Attributes>;
using InterfaceName = std::string;
-using InterfaceMap = std::map<InterfaceName, PropertyMap>;
+using InterfaceMap = std::unordered_map<InterfaceName, PropertyMap>;
using Service = std::string;
using Path = std::string;
using Interface = std::string;
using Interfaces = std::vector<Interface>;
-using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>;
+using MapperResponseType =
+ std::unordered_map<Path, std::unordered_map<Service, Interfaces>>;
using ResourceNotFoundErr =
sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound;
@@ -52,7 +53,7 @@
MAPPER_IFACE, "GetObject");
mapper.append(path.c_str(), std::vector<std::string>({OBJMGR_IFACE}));
- std::map<std::string, std::vector<std::string>> mapperResponse;
+ std::unordered_map<std::string, std::vector<std::string>> mapperResponse;
try
{
auto mapperResponseMsg = bus.call(mapper);
diff --git a/fault-monitor/operational-status-monitor.cpp b/fault-monitor/operational-status-monitor.cpp
index de6ee21..1114463 100644
--- a/fault-monitor/operational-status-monitor.cpp
+++ b/fault-monitor/operational-status-monitor.cpp
@@ -23,7 +23,7 @@
// Get all the properties of
// "xyz.openbmc_project.State.Decorator.OperationalStatus" interface
std::string interfaceName{};
- std::map<std::string, std::variant<bool>> properties;
+ std::unordered_map<std::string, std::variant<bool>> properties;
msg.read(interfaceName, properties);
const auto it = properties.find("Functional");