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.
--- 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)