diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index b09cf7c7db9dc31dae05cc02577076b2e8431186..b0d17877dcb89eb44795ad64e19d181610a6d413 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -534,9 +534,12 @@ def regenerate(self, all_specs, roots): tty.msg("Updating view at {0}".format(self.root)) rm_specs = specs_in_view - installed_specs_for_view - view.remove_specs(*rm_specs, with_dependents=False) - add_specs = installed_specs_for_view - specs_in_view + + # pass all_specs in, as it's expensive to read all the + # spec.yaml files twice. + view.remove_specs(*rm_specs, with_dependents=False, + all_specs=specs_in_view) view.add_specs(*add_specs, with_dependencies=False) diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py index 448254f26b311c91a759c9df435b836ee7aec46a..5455ccb1077493cd963f2a36d3946d610547fa64 100644 --- a/lib/spack/spack/filesystem_view.py +++ b/lib/spack/spack/filesystem_view.py @@ -371,6 +371,9 @@ def remove_specs(self, *specs, **kwargs): with_dependents = kwargs.get("with_dependents", True) with_dependencies = kwargs.get("with_dependencies", False) + # caller can pass this in, as get_all_specs() is expensive + all_specs = kwargs.get("all_specs", None) or set(self.get_all_specs()) + specs = set(specs) if with_dependencies: @@ -379,8 +382,6 @@ def remove_specs(self, *specs, **kwargs): if kwargs.get("exclude", None): specs = set(filter_exclude(specs, kwargs["exclude"])) - all_specs = set(self.get_all_specs()) - to_deactivate = specs to_keep = all_specs - to_deactivate