From 882d14c514b1d7f2b36c0c0fe873a1db359694ed Mon Sep 17 00:00:00 2001 From: Jonathan Bastien-Filiatrault Date: Wed, 12 Dec 2018 13:40:55 -0500 Subject: [PATCH] Avoid making a fresh slice of the whole email on each iteration. An update to yesterday's patch. Should avoid copying the mail byte string more than once. Tested on Python 2.7 and 3.6. --- dkim/canonicalization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkim/canonicalization.py b/dkim/canonicalization.py index 8c9ffc1..1860848 100644 --- a/dkim/canonicalization.py +++ b/dkim/canonicalization.py @@ -42,7 +42,7 @@ def compress_whitespace(content): def strip_trailing_lines(content): end = None - while content[:end].endswith(b"\r\n"): + while content.endswith(b"\r\n", 0, end): if end is None: end = -2 else: