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.
1 files changed, 2 insertions(+), 2 deletions(-)

M mercurial/ui.py
M mercurial/ui.py +2 -2
@@ 1006,8 1006,8 @@ class ui(object):
     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)