Skip to content

Commit

Permalink
objects: don't recompute object size
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed May 31, 2022
1 parent d191e14 commit a183213
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scmrepo/git/backend/dulwich/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def scandir(self) -> Iterable["DulwichObject"]:
self.repo, entry.path.decode(), entry.mode, entry.sha
)

@property
def size(self) -> int:
@cached_property
def size(self) -> int: # pylint: disable=invalid-overridden-method
return len(self.repo[self.sha].as_raw_string())

@property
Expand Down
4 changes: 2 additions & 2 deletions scmrepo/git/backend/pygit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def mode(self):
return stat.S_IFDIR
return self.obj.filemode

@property
def size(self) -> int:
@cached_property
def size(self) -> int: # pylint: disable=invalid-overridden-method
try:
return len(self.obj.read_raw())
except KeyError:
Expand Down

0 comments on commit a183213

Please sign in to comment.