From 5375e154d828e1901e3f06e107a6d2c0eb345ee2 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Mon, 17 Dec 2018 22:17:02 +0000 Subject: [PATCH] Add in configuration caching to potentially avoid an unnecessary lookup. --- volatility/framework/interfaces/configuration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/volatility/framework/interfaces/configuration.py b/volatility/framework/interfaces/configuration.py index 87a3ee9dd..cb704e5ba 100644 --- a/volatility/framework/interfaces/configuration.py +++ b/volatility/framework/interfaces/configuration.py @@ -464,6 +464,7 @@ class ConfigurableInterface(validity.ValidityRoutines, metaclass = ABCMeta): super().__init__() self._context = self._check_type(context, ContextInterface) self._config_path = self._check_type(config_path, str) + self._config_cache = None @property def context(self) -> 'interfaces.context.ContextInterface': @@ -476,11 +477,14 @@ class ConfigurableInterface(validity.ValidityRoutines, metaclass = ABCMeta): @config_path.setter def config_path(self, value: str) -> None: self._config_path = self._check_type(value, str) + self._config_cache = None @property def config(self) -> HierarchicalDict: """The Hierarchical configuration Dictionary for this Configurable object""" - return self._context.config.branch(self._config_path) + if self._config_cache is None: + self._config_cache = self._context.config.branch(self._config_path) + return self._config_cache def build_configuration(self) -> HierarchicalDict: """Constructs a HierarchicalDictionary of all the options required to build this component in the current context.