ui: optimize buffered write with no label stable
authorYuya Nishihara <yuya@tcha.org>
Wed, 28 Nov 2018 22:36:24 +0900
branchstable
changeset 41304 ff927ecb12f9
parent 41303 76873548b051
child 41305 b4a3abdc790d
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.
mercurial/ui.py
--- 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)