changeset 40522:51091816a355

ui: simply concatenate messages before applying color labels This should be cheaper in space than applying labels for each message.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Nov 2018 17:42:05 +0900
parents 49746e53ac92
children 0c7b2035a604
files mercurial/color.py mercurial/ui.py
diffstat 2 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/color.py	Sat Nov 03 17:36:10 2018 +0900
+++ b/mercurial/color.py	Sat Nov 03 17:42:05 2018 +0900
@@ -487,11 +487,7 @@
             ansire = re.compile(b'\033\[([^m]*)m([^\033]*)(.*)',
                                 re.MULTILINE | re.DOTALL)
 
-    def win32print(ui, writefunc, *msgs, **opts):
-        for text in msgs:
-            _win32print(ui, text, writefunc, **opts)
-
-    def _win32print(ui, text, writefunc, **opts):
+    def win32print(ui, writefunc, text, **opts):
         label = opts.get(r'label', '')
         attr = origattr
 
--- a/mercurial/ui.py	Sat Nov 03 17:36:10 2018 +0900
+++ b/mercurial/ui.py	Sat Nov 03 17:42:05 2018 +0900
@@ -951,16 +951,16 @@
 
     def _writenobuf(self, write, *args, **opts):
         self._progclear()
+        msg = b''.join(args)
         if self._colormode == 'win32':
             # windows color printing is its own can of crab, defer to
             # the color module and that is it.
-            color.win32print(self, write, *args, **opts)
+            color.win32print(self, write, msg, **opts)
         else:
-            msgs = args
             if self._colormode is not None:
                 label = opts.get(r'label', '')
-                msgs = [self.label(a, label) for a in args]
-            write(b''.join(msgs))
+                msg = self.label(msg, label)
+            write(msg)
 
     def _write(self, data):
         # opencode timeblockedsection because this is a critical path