diff options
author | Holger Freyther <ich@tamarin.(none)> | 2009-05-19 13:53:12 +0200 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-02-15 17:07:54 +0000 |
commit | 83ec5eaed411225d16a4fc4dc92323e3acc9f5cd (patch) | |
tree | 675f08265c9de79ec267002b11bf3e727c2a73ae /bitbake/lib | |
parent | c011d42eda4b830ec2a609817b61d166ff0413d4 (diff) | |
download | openembedded-core-83ec5eaed411225d16a4fc4dc92323e3acc9f5cd.tar.gz openembedded-core-83ec5eaed411225d16a4fc4dc92323e3acc9f5cd.tar.bz2 openembedded-core-83ec5eaed411225d16a4fc4dc92323e3acc9f5cd.tar.xz openembedded-core-83ec5eaed411225d16a4fc4dc92323e3acc9f5cd.zip |
bitbake: [parser] Cache parsed .inc and .bbclass files for a parse speedup
Have a growing dict with .inc and .bbclass'es. This avoids to reparse
files we have already seen.
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 9b8ad0b9e..ab479c1eb 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -50,6 +50,8 @@ __body__ = [] __classname__ = "" classes = [ None, ] +cached_statements = {} + # We need to indicate EOF to the feeder. This code is so messy that # factoring it out to a close_parse_file method is out of question. # We will use the IN_PYTHON_EOF as an indicator to just close the method @@ -79,20 +81,27 @@ def inherit(files, d): __inherit_cache = data.getVar('__inherit_cache', d) or [] def get_statements(filename, absolsute_filename, base_name, file): - statements = ast.StatementGroup() - - lineno = 0 - while 1: - lineno = lineno + 1 - s = file.readline() - if not s: break - s = s.rstrip() - feeder(lineno, s, filename, base_name, statements) - if __inpython__: - # add a blank line to close out any python definition - feeder(IN_PYTHON_EOF, "", filename, base_name, statements) - - return statements + global cached_statements + + try: + return cached_statements[absolsute_filename] + except KeyError: + statements = ast.StatementGroup() + + lineno = 0 + while 1: + lineno = lineno + 1 + s = file.readline() + if not s: break + s = s.rstrip() + feeder(lineno, s, filename, base_name, statements) + if __inpython__: + # add a blank line to close out any python definition + feeder(IN_PYTHON_EOF, "", filename, base_name, statements) + + if filename.endswith(".bbclass") or filename.endswith(".inc"): + cached_statements[absolsute_filename] = statements + return statements def handle(fn, d, include): global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ |