Mercurial > public > mercurial-scm > hg-stable
diff hgdemandimport/demandimportpy3.py @ 37889:670eb4fa1b86
demandimport: make module ignores a set (API)
The list of modules to ignore is used for membership testing. Yet
it is defined as a list.
Sets are more efficient for membership testing. So this commit converts
the module list to a set.
Since we took an API hit, I renamed the variable to further clarify
the change.
This appears to reduce the CPU time for running 300 invocations of
`hg log -r. -T '{rev}'` on my i7-6700K:
before: 18.64s
after: 18.44s
Differential Revision: https://phab.mercurial-scm.org/D3440
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 05 May 2018 18:41:51 -0700 |
parents | fcb1ecf2bef7 |
children | adb636392b3f |
line wrap: on
line diff
--- a/hgdemandimport/demandimportpy3.py Thu Apr 19 20:33:43 2018 +0900 +++ b/hgdemandimport/demandimportpy3.py Sat May 05 18:41:51 2018 -0700 @@ -40,7 +40,7 @@ """ def exec_module(self, module): """Make the module load lazily.""" - if _deactivated or module.__name__ in ignore: + if _deactivated or module.__name__ in ignores: self.loader.exec_module(module) else: super().exec_module(module) @@ -62,11 +62,11 @@ (_bytecode_loader, importlib.machinery.BYTECODE_SUFFIXES), ) -ignore = [] +ignores = set() -def init(ignorelist): - global ignore - ignore = ignorelist +def init(ignoreset): + global ignores + ignores = ignoreset def isenabled(): return _makefinder in sys.path_hooks and not _deactivated