Skip to content

Commit

Permalink
Move lru_cache definitions to __init__ (#21)
Browse files Browse the repository at this point in the history
Using the lru_cache decorators on class methods, the ones that have a reference to `self`,
will also cache self. So we move it to the __init__ of the class

(DIS-2913)
  • Loading branch information
Miauwkeru committed Feb 20, 2024
1 parent 4ad2fc3 commit de0c6c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dissect/regf/regf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def __init__(self, fh):
log.debug(f"Hive {self.filename!r} is not undergoing any transactions.")

self.hbin_offset = 4096

self.cell = lru_cache(4096)(self.cell)

self._root = self.cell(self.header.root_key_offset)

def root(self):
Expand Down Expand Up @@ -105,7 +108,6 @@ def parse_cell_data(self, data):

raise NotImplementedError(repr(sig))

@lru_cache(4096)
def cell(self, offset):
return self.read_cell(offset)

Expand Down

0 comments on commit de0c6c5

Please sign in to comment.