mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-20 17:52:50 +00:00
storage.py : replace 4294967295 with 2**32-1: python does constant folding, I measured this statement as taking 50ns, versus the 400ns for the call to min(), or the 9us required for the 'assert not os.path.exists' syscall
This commit is contained in:
parent
c7cd3f38e7
commit
167742c2b3
@ -112,15 +112,16 @@ class ShareFile:
|
||||
assert not os.path.exists(self.home)
|
||||
fileutil.make_dirs(os.path.dirname(self.home))
|
||||
f = open(self.home, 'wb')
|
||||
# The second field -- share data length -- is no longer used as of Tahoe v1.3.0, but
|
||||
# we continue to write it in there in case someone downgrades a storage server from
|
||||
# >= Tahoe-1.3.0 to < Tahoe-1.3.0, or moves a share file from one server to another,
|
||||
# etc. We do saturation -- a share data length larger than what can fit into the
|
||||
# field is marked as the largest length that can fit into the field. That way, even
|
||||
# if this does happen, the old < v1.3.0 server will still allow clients to read the
|
||||
# first part of the share. The largest size that will fit in this 4-byte field is
|
||||
# 2**32-1, or 4294967295.
|
||||
f.write(struct.pack(">LLL", 1, min(4294967295, max_size), 0))
|
||||
# The second field -- the four-byte share data length -- is no
|
||||
# longer used as of Tahoe v1.3.0, but we continue to write it in
|
||||
# there in case someone downgrades a storage server from >=
|
||||
# Tahoe-1.3.0 to < Tahoe-1.3.0, or moves a share file from one
|
||||
# server to another, etc. We do saturation -- a share data length
|
||||
# larger than 2**32-1 (what can fit into the field) is marked as
|
||||
# the largest length that can fit into the field. That way, even
|
||||
# if this does happen, the old < v1.3.0 server will still allow
|
||||
# clients to read the first part of the share.
|
||||
f.write(struct.pack(">LLL", 1, min(2**32-1, max_size), 0))
|
||||
f.close()
|
||||
self._lease_offset = max_size + 0x0c
|
||||
self._num_leases = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user