From 2c293542b82279879961d8ee9f81c59af14df95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Tue, 3 Mar 2026 22:10:31 -0300 Subject: [PATCH] perf(python-dotenv): replace findall with str-count in advance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matheus Virgolino Co-authored-by: Manoel Netto Co-authored-by: Pedro Co-authored-by: Lucaslg7 Co-authored-by: RailtonDantas Co-authored-by: João Pereira --- src/dotenv/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotenv/parser.py b/src/dotenv/parser.py index eb100b47..701aff58 100644 --- a/src/dotenv/parser.py +++ b/src/dotenv/parser.py @@ -59,7 +59,7 @@ def set(self, other: "Position") -> None: def advance(self, string: str) -> None: self.chars += len(string) - self.line += len(re.findall(_newline, string)) + self.line += string.count("\n") + string.count("\r") - string.count("\r\n") class Error(Exception):