Skip to content

Commit

Permalink
Move lru_cache definitions down
Browse files Browse the repository at this point in the history
  • Loading branch information
Miauwkeru committed Feb 20, 2024
1 parent 50520ff commit 3ee314c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dissect/squashfs/squashfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class SquashFS:
def __init__(self, fh: BinaryIO):
self.fh = fh

self._read_block = lru_cache(1024)(self._read_block)
self._lookup_id = lru_cache(1024)(self._lookup_id)
self._lookup_inode = lru_cache(1024)(self._lookup_inode)
self._lookup_fragment = lru_cache(1024)(self._lookup_fragment)

sb = c_squashfs.squashfs_super_block(fh)
if sb.s_magic != c_squashfs.SQUASHFS_MAGIC:
raise ValueError("Invalid squashfs superblock")
Expand All @@ -51,6 +46,11 @@ def __init__(self, fh: BinaryIO):
self.minor = self.sb.s_minor
self.size = self.sb.bytes_used

self._read_block = lru_cache(1024)(self._read_block)
self._lookup_id = lru_cache(1024)(self._lookup_id)
self._lookup_inode = lru_cache(1024)(self._lookup_inode)
self._lookup_fragment = lru_cache(1024)(self._lookup_fragment)

self._compression_options = None
if (self.sb.flags >> c_squashfs.SQUASHFS_COMP_OPT) & 1:
self._compression_options = self._read_block(len(self.sb))[1]
Expand Down

0 comments on commit 3ee314c

Please sign in to comment.