changeset 41306:b4a3abdc790d stable

ui: inline _write() into write() due to performance issue I'll remove redundant conditions later in this series.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 24 Jan 2019 21:34:48 +0900
parents ff927ecb12f9
children e8273eaa0726
files mercurial/ui.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Wed Nov 28 22:36:24 2018 +0900
+++ b/mercurial/ui.py	Thu Jan 24 21:34:48 2019 +0900
@@ -999,12 +999,23 @@
         "cmdname.type" is recommended. For example, status issues
         a label of "status.modified" for modified files.
         '''
-        self._write(self._fout, *args, **opts)
+        dest = self._fout
+
+        # inlined _write() for speed
+        if self._isbuffered(dest):
+            label = opts.get(r'label', '')
+            if label and self._bufferapplylabels:
+                self._buffers[-1].extend(self.label(a, label) for a in args)
+            else:
+                self._buffers[-1].extend(args)
+        else:
+            self._writenobuf(dest, *args, **opts)
 
     def write_err(self, *args, **opts):
         self._write(self._ferr, *args, **opts)
 
     def _write(self, dest, *args, **opts):
+        # update write() as well if you touch this code
         if self._isbuffered(dest):
             label = opts.get(r'label', '')
             if label and self._bufferapplylabels: