ui.write: don't clear progress bar when writing to a buffer
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 14 Nov 2015 17:14:14 -0800
changeset 27068 9eeca021a803
parent 27067 19b52cde2b84
child 27069 4e554a7df1e9
ui.write: don't clear progress bar when writing to a buffer ui.write() has 2 modes: buffered and unbuffered. In buffered mode, we capture output before writing it. This is how changeset printing works, for example. Previously, we were potentially clearing the progress bar for every call to ui.write(). In buffered mode, this clearing was useless because the clearing function would be called again before actually writing the buffered data. This patch stops the useless calling of _progclear() unless we are actually writing data. During changeset printing with the default template, this removes ~6 function calls per changeset, making changeset printing slightly faster. before: 23.76s after: 23.35s delta: -0.41s (98.3% of original)
mercurial/ui.py
--- a/mercurial/ui.py	Sun Nov 22 21:20:08 2015 -0500
+++ b/mercurial/ui.py	Sat Nov 14 17:14:14 2015 -0800
@@ -612,10 +612,10 @@
         "cmdname.type" is recommended. For example, status issues
         a label of "status.modified" for modified files.
         '''
-        self._progclear()
         if self._buffers:
             self._buffers[-1].extend([str(a) for a in args])
         else:
+            self._progclear()
             for a in args:
                 self.fout.write(str(a))