mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-23 14:42:25 +02:00
Remove the chainmap and multiple dictionaries to reduce memory consumption
This commit is contained in:
@@ -133,8 +133,10 @@ class ObjectInterface(metaclass=abc.ABCMeta):
|
||||
mask = context.layers[object_info.layer_name].address_mask
|
||||
normalized_offset = object_info.offset & mask
|
||||
|
||||
self._vol = kwargs
|
||||
vol_info_dict = {"type_name": type_name, "offset": normalized_offset}
|
||||
self._vol = collections.ChainMap({}, vol_info_dict, object_info, kwargs)
|
||||
self._vol.update(object_info)
|
||||
self._vol.update(vol_info_dict)
|
||||
self._context = context
|
||||
|
||||
def __getattr__(self, attr: str) -> Any:
|
||||
@@ -317,10 +319,8 @@ class Template:
|
||||
"""Stores the keyword arguments for later object creation."""
|
||||
# Allow the updating of template arguments whilst still in template form
|
||||
super().__init__()
|
||||
empty_dict: Dict[str, Any] = {}
|
||||
self._vol = collections.ChainMap(
|
||||
empty_dict, arguments, {"type_name": type_name}
|
||||
)
|
||||
self._vol = {"type_name": type_name}
|
||||
self._vol.update(arguments)
|
||||
|
||||
@property
|
||||
def vol(self) -> ReadOnlyMapping:
|
||||
@@ -364,7 +364,7 @@ class Template:
|
||||
def clone(self) -> "Template":
|
||||
"""Returns a copy of the original Template as constructed (without
|
||||
`update_vol` additions having been made)"""
|
||||
clone = self.__class__(**self._vol.parents.new_child())
|
||||
clone = self.__class__(**self._vol)
|
||||
return clone
|
||||
|
||||
def update_vol(self, **new_arguments) -> None:
|
||||
|
||||
@@ -61,7 +61,7 @@ class TreeNode(interfaces.renderers.TreeNode):
|
||||
self._treegrid = treegrid
|
||||
self._parent = parent
|
||||
self._path = path
|
||||
self._validate_values(values)
|
||||
validated_values = self._validate_values(values)
|
||||
self._values = treegrid.RowStructure(*values) # type: ignore
|
||||
|
||||
def __repr__(self) -> str:
|
||||
@@ -73,9 +73,12 @@ class TreeNode(interfaces.renderers.TreeNode):
|
||||
def __len__(self) -> int:
|
||||
return len(self._treegrid.children(self))
|
||||
|
||||
def _validate_values(self, values: List[interfaces.renderers.BaseTypes]) -> None:
|
||||
def _validate_values(
|
||||
self, values: List[interfaces.renderers.BaseTypes]
|
||||
) -> List[interfaces.renderers.BaseTypes]:
|
||||
"""A function for raising exceptions if a given set of values is
|
||||
invalid according to the column properties."""
|
||||
new_values = ()
|
||||
if not (
|
||||
isinstance(values, collections.abc.Sequence)
|
||||
and len(values) == len(self._treegrid.columns)
|
||||
|
||||
Reference in New Issue
Block a user