ui: cache a progress config check

Summary:
During profiling of the `hg sparse --refresh` command, I discovered
significant time spent in producing the progress bar. At first I was skeptical,
but then I commented out the progress line and the command took half as long!

I started looking for micro-optiization opportunities.

Differential Revision: D7210617

fbshipit-source-id: 17a11ae572fee48e6d8db33ca75843be0ec2e850
This commit is contained in:
Ryan McElroy 2018-03-12 08:02:14 -07:00 committed by Saurabh Singh
parent 7c94c47d99
commit 4a02cd42df

View File

@ -1533,6 +1533,7 @@ class ui(object):
@util.propertycache
def _progbar(self):
"""setup the progbar singleton to the ui object"""
self._progdebug = self.configbool('progress', 'debug')
if (self.quiet or self.debugflag
or self.configbool('progress', 'disable')
or not progress.shouldprint(self)):
@ -1564,7 +1565,7 @@ class ui(object):
if self._progbar is not None:
self._progbar.progress(topic, pos, item=item, unit=unit,
total=total)
if pos is None or not self.configbool('progress', 'debug'):
if pos is None or not self._progdebug:
return
if unit: