mercurial/utils/stringutil.py
changeset 49030 75794847ef62
parent 49021 51aed118f9dc
child 49284 d44e3c45f0e4
--- a/mercurial/utils/stringutil.py	Thu Mar 24 22:05:49 2022 -0700
+++ b/mercurial/utils/stringutil.py	Fri Mar 25 08:33:03 2022 -0700
@@ -687,6 +687,10 @@
 
 def firstline(text):
     """Return the first line of the input"""
+    # Try to avoid running splitlines() on the whole string
+    i = text.find(b'\n')
+    if i != -1:
+        text = text[:i]
     try:
         return text.splitlines()[0]
     except IndexError: