Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 27068:9eeca021a803
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)
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 14 Nov 2015 17:14:14 -0800 |
parents | 5e46123e6c35 |
children | 6ef17697b03d |
comparison
equal
deleted
inserted
replaced
27067:19b52cde2b84 | 27068:9eeca021a803 |
---|---|
610 | 610 |
611 When labeling output for a specific command, a label of | 611 When labeling output for a specific command, a label of |
612 "cmdname.type" is recommended. For example, status issues | 612 "cmdname.type" is recommended. For example, status issues |
613 a label of "status.modified" for modified files. | 613 a label of "status.modified" for modified files. |
614 ''' | 614 ''' |
615 self._progclear() | |
616 if self._buffers: | 615 if self._buffers: |
617 self._buffers[-1].extend([str(a) for a in args]) | 616 self._buffers[-1].extend([str(a) for a in args]) |
618 else: | 617 else: |
618 self._progclear() | |
619 for a in args: | 619 for a in args: |
620 self.fout.write(str(a)) | 620 self.fout.write(str(a)) |
621 | 621 |
622 def write_err(self, *args, **opts): | 622 def write_err(self, *args, **opts): |
623 self._progclear() | 623 self._progclear() |