upload-release: Avoid appending to bytes in a loop.

Appending to bytes in a loop leads to a quadratic slowdown since
Python doesn’t optimize this for bytes like it does for str.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-12-28 13:30:39 -08:00 committed by Tim Abbott
parent 80e4d5436d
commit f9271098bf
1 changed files with 3 additions and 3 deletions

View File

@ -96,14 +96,14 @@ if ordered_filenames[1] == new_basename:
file_hashes["zulip-server-latest.tar.gz"] = file_hashes[new_basename]
print("Updating SHA256SUMS.txt..")
contents = b""
contents = ""
for ordered_filename in ordered_filenames:
# natsorted type annotation is insufficiently generic
assert isinstance(ordered_filename, str)
contents += f"{file_hashes[ordered_filename]} {ordered_filename}\n".encode()
contents += f"{file_hashes[ordered_filename]} {ordered_filename}\n"
bucket.put_object(
ACL="public-read",
Body=contents,
Body=contents.encode(),
ContentType="text/plain",
Key="server/SHA256SUMS.txt",
)