summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-05-28 22:01:58 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-05-28 23:05:23 -0700
commite8b4d5fb6ffe18bcb93a86d00fbfb1ed37d0db3b (patch)
tree632696fa133a3b33fc09ec8f32b2422965c4943d /lib
parent6dcdb50a3e61af006c372617e7228b2f05958446 (diff)
downloadspack-e8b4d5fb6ffe18bcb93a86d00fbfb1ed37d0db3b.tar.gz
spack-e8b4d5fb6ffe18bcb93a86d00fbfb1ed37d0db3b.tar.bz2
spack-e8b4d5fb6ffe18bcb93a86d00fbfb1ed37d0db3b.tar.xz
spack-e8b4d5fb6ffe18bcb93a86d00fbfb1ed37d0db3b.zip
Performance boost: reduce instantiations of re.Scanner
- Lexer is the same for every Spec parser in spack, so don't build it every time. - This improves time to import package.py files a lot, as a Lexer doesn't have to be constructed for every spc in the packages. - To concretize dealii: - Before: ~20 sec - After: ~6 sec
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 7c09af4c21..16b61236a9 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2015,10 +2015,13 @@ class SpecLexer(spack.parse.Lexer):
(r'\s+', lambda scanner, val: None)])
+# Lexer is always the same for every parser.
+_lexer = SpecLexer()
+
class SpecParser(spack.parse.Parser):
def __init__(self):
- super(SpecParser, self).__init__(SpecLexer())
+ super(SpecParser, self).__init__(_lexer)
self.previous = None
def do_parse(self):