Skip to content

Commit

Permalink
It turns out that cloning native_templates was unnecessary or slow. F…
Browse files Browse the repository at this point in the history
…ix and document why clearly.
  • Loading branch information
ikelos committed Aug 9, 2018
1 parent 19bdc36 commit 99f8859
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion volatility/framework/symbols/intermed.py
Expand Up @@ -307,7 +307,8 @@ def _interdict_to_template(self, dictionary: typing.Dict[str, typing.Any]) -> in
elif type_name == 'bitfield':
update = {'start_bit': dictionary['bit_position'], 'end_bit': dictionary['bit_length']}
update['base_type'] = self._interdict_to_template(dictionary['type'])
native_template = native_template.clone()
# We do *not* call native_template.clone(), since it slows everything down a lot
# We require that the native.get_type method always returns a newly constructed python object
native_template.update_vol(**update)
return native_template

Expand Down
3 changes: 2 additions & 1 deletion volatility/framework/symbols/native.py
Expand Up @@ -33,7 +33,8 @@ def types(self) -> typing.Iterable[str]:
def get_type(self, type_name: str) -> interfaces.objects.Template:
"""Resolves a symbol name into an object template
symbol_space is used to resolve any subtype symbols if they don't exist in this list
This always construct a new python object, rather than using a cached value otherwise changes made later may
affect the cached copy. Calling clone after every native type construction was extremely slow.
"""
# NOTE: These need updating whenever the object init signatures change
prefix = ""
Expand Down

0 comments on commit 99f8859

Please sign in to comment.