changeset 41305:ff927ecb12f9 stable

ui: optimize buffered write with no label This was spotted while making fastannotate faster again after ditching its own formatter. Since I'm going to inline _write() into ui.write(), I decided to include this patch in this series. Here, the cost of '(self.label(a, label) for a in args)' was significant in hot loops.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 28 Nov 2018 22:36:24 +0900
parents 76873548b051
children b4a3abdc790d
files mercurial/ui.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Wed Jan 23 18:07:42 2019 -0500
+++ b/mercurial/ui.py	Wed Nov 28 22:36:24 2018 +0900
@@ -1006,8 +1006,8 @@
 
     def _write(self, dest, *args, **opts):
         if self._isbuffered(dest):
-            if self._bufferapplylabels:
-                label = opts.get(r'label', '')
+            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)