make isDCMIPowerMgmtSupported cache response
isDCMIPowerMgmtSupported is called a lot if any of the DCMI commands
are used, so it makes sense to cache the value rather than constantly
re-parsing the JSON file, especially since it won't change except for
on a fw update.
Tested: DCMI power management commands continue to work as before.
Change-Id: Id0deb40c4a5332d5f96d7dda6d958f20925c01a9
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index ca2ee7d..8052214 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -68,9 +68,16 @@
bool isDCMIPowerMgmtSupported()
{
- auto data = parseJSONConfig(gDCMICapabilitiesConfig);
+ static bool parsed = false;
+ static bool supported = false;
+ if (!parsed)
+ {
+ auto data = parseJSONConfig(gDCMICapabilitiesConfig);
- return (gDCMIPowerMgmtSupported == data.value(gDCMIPowerMgmtCapability, 0));
+ supported = (gDCMIPowerMgmtSupported ==
+ data.value(gDCMIPowerMgmtCapability, 0));
+ }
+ return supported;
}
uint32_t getPcap(sdbusplus::bus_t& bus)