Commit 82d2f907 authored by Tristan Gingold's avatar Tristan Gingold

optimization: do not reparse modules already loaded.

parent b20754ab
......@@ -48,26 +48,23 @@ class Action(object):
self._deps_solved = False
self.options = options
def __contains(self, module):
"""Check if the pool contains the given module by checking the URL"""
for mod in self.manifests:
if mod.url == module.url:
return True
return False
def new_module(self, parent, url, source, fetchto):
"""Add new module to the pool.
This is the only way to add new modules to the pool
Thanks to it the pool can easily control its content
"""
# If the module is already present, do not create it.
for mod in self.manifests:
if mod.url == url:
return None
# A new module will be added, dependencies have to be computed.
self._deps_solved = False
args = ModuleArgs()
args.set_args(parent, url, source, fetchto)
new_module = Module(args, self)
if not self.__contains(new_module):
self.manifests.append(new_module)
return new_module
res = Module(args, self)
self.manifests.append(res)
return res
def load_all_manifests(self):
# Load the top level module (which is in the current directory).
......@@ -153,6 +150,7 @@ class Action(object):
self.tool.get_standard_libs())
self._deps_solved = True
if self.options.all_files:
# If option -all is used, no need to compute dependencies.
return
solved_files = SourceFileSet()
solved_files.add(dep_solver.make_dependency_set(
......
......@@ -262,8 +262,11 @@ class Module(object):
raise Exception("Found an absolute path (" + path +
") in a manifest(" + self.path + ")")
path = path_mod.rel2abs(path, self.path)
mods.append(self.action.new_module(
parent=self, url=path, source=m, fetchto=fetchto))
# Create a module if not already loaded.
mod = self.action.new_module(
parent=self, url=path, source=m, fetchto=fetchto)
if mod is not None:
mods.append(mod)
self.modules[m] = mods
def _process_manifest_makefiles(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment