Skip to content

Commit

Permalink
prefer KeysView iterable to lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Abyss-W4tcher committed Jan 18, 2025
1 parent 1e9551b commit aa99410
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions volatility3/framework/symbols/intermed.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,23 @@ def get_symbol(self, name: str) -> interfaces.symbols.SymbolInterface:

@property
def symbols(self) -> Iterable[str]:
"""Returns an iterator of the symbol names."""
return list(self._json_object.get("symbols", {}))
"""Returns an iterable (KeysView) of the available symbol names."""
return self._json_object.get("symbols", {}).keys()

@property
def enumerations(self) -> Iterable[str]:
"""Returns an iterator of the available enumerations."""
return list(self._json_object.get("enums", {}))
def enumerations(self) -> Iterable[Any]:
"""Returns an iterable (KeysView) of the available enumerations."""
return self._json_object.get("enums", {}).keys()

@property
def types(self) -> Iterable[str]:
"""Returns an iterator of the symbol type names."""
return list(self._json_object.get("user_types", {})) + list(self.natives.types)
def types(self):
"""Returns an iterable (KeysView) of the available symbol type names."""
# self.natives.types (set) is generally very small compared to user_types,
# so the dict conversion overhead can be neglected
return {
**self._json_object.get("user_types", {}),
**dict.fromkeys(self.natives.types),
}.keys()

def get_type_class(self, name: str) -> Type[interfaces.objects.ObjectInterface]:
return self._overrides.get(name, objects.AggregateType)
Expand Down

0 comments on commit aa99410

Please sign in to comment.