test_console_output: 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:32:36 -08:00
committed by Tim Abbott
parent f9271098bf
commit b0b8f84949

View File

@@ -35,7 +35,7 @@ class ExtraConsoleOutputFinder:
]
self.compiled_line_pattern = re.compile(b"|".join(valid_line_patterns))
self.partial_line = b""
self.full_extra_output = b""
self.full_extra_output = bytearray()
def find_extra_output(self, data: bytes) -> None:
*lines, self.partial_line = (self.partial_line + data).split(b"\n")