Skip to content

Commit

Permalink
Move lru_cache definitions to __init__ (#20)
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 authored Feb 20, 2024
1 parent 430dda3 commit f0b8dc4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dissect/fat/fat.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def __init__(self, fh, fattype):

self.entry_count = int(self.fh.size // (self.bits_per_entry / 8))

@lru_cache(4096)
self.get = lru_cache(4096)(self.get)

def get(self, cluster):
if cluster >= self.entry_count:
raise ValueError(f"Cluster exceeds FAT entry count: {cluster} >= {self.entry_count}")
Expand Down

0 comments on commit f0b8dc4

Please sign in to comment.