[PATCH 3 of 5] ui.write: don't clear progress bar when writing to a buffer
Gregory Szorc
gregory.szorc at gmail.com
Sun Nov 22 04:14:28 UTC 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1447550054 28800
# Sat Nov 14 17:14:14 2015 -0800
# Node ID 2ec388664377f3e729a60d718092d625efd4f50b
# Parent 661c3760dd2a9aac51bf992a14be493206b51c0a
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)
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -607,20 +607,20 @@ class ui(object):
This should be a string containing label names separated by
space. Label names take the form of "topic.type". For example,
ui.debug() issues a label of "ui.debug".
When labeling output for a specific command, a label of
"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))
def write_err(self, *args, **opts):
self._progclear()
try:
if self._bufferstates and self._bufferstates[-1][0]:
return self.write(*args, **opts)
More information about the Mercurial-devel
mailing list