diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2018-01-22 17:08:00 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2018-01-22 17:08:00 (GMT) |
commit | 482bbca1532cb100c89a23fb28736857e3d83518 (patch) | |
tree | f50422417d81fb26ee43dec61b29a592aa31ce98 | |
parent | dc8b667fc3e6bf855762deb775c83ea12bd07a6b (diff) |
Checking out each entry just for determining the file size is very
expensive. Try looking up the filesize property first and use it if
available. Compared to checking out the entry this is so much cheaper
that the additional overhead in case the property isn't
available (unlikely) doesn't really matter. And in the other case it's
a huge speed-up.
-rw-r--r-- | fsemulation.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fsemulation.py b/fsemulation.py index 8e89fef..7f004a0 100644 --- a/fsemulation.py +++ b/fsemulation.py @@ -440,7 +440,9 @@ class DataStore(object): @synchronised def get_size(self, object_id): - # FIXME: make use of filesize property if available + props = self.get_properties(object_id, ['filesize']) + if props.get('filesize'): + return int(props['filesize']) path = self.get_data(object_id) if not path: return 0 |