From 98e35879e30a463fedbbde8c3cf442b259b381c8 Mon Sep 17 00:00:00 2001 From: Michael Adkins Date: Mon, 28 Mar 2022 10:48:16 -0500 Subject: [PATCH] Improve bytearray cast comment --- h11/_readers.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/h11/_readers.py b/h11/_readers.py index 5ad88a9..89545c2 100644 --- a/h11/_readers.py +++ b/h11/_readers.py @@ -37,9 +37,6 @@ __all__ = ["READERS"] header_field_re = re.compile(header_field.encode("ascii")) - -# Remember that this has to run in O(n) time -- so e.g. the bytearray cast is -# critical. obs_fold_re = re.compile(rb"[ \t]+") @@ -52,6 +49,7 @@ def _obsolete_line_fold(lines: Iterable[bytes]) -> Iterable[bytes]: if last is None: raise LocalProtocolError("continuation line at start of headers") if not isinstance(last, bytearray): + # Cast to a mutable type, avoiding copy on append to ensure O(n) time last = bytearray(last) last += b" " last += line[match.end() :]