spack remove: fix traversal when user specs intersect (#37882)

drop unnecessary double loop over the matching user specs.
This commit is contained in:
Harmen Stoppels 2023-05-24 15:23:46 +02:00 committed by Massimiliano Culpo
parent 0052f330be
commit f2d3818d5c

View File

@ -1221,7 +1221,8 @@ def remove(self, query_spec, list_name=user_speclist_name, force=False):
old_specs = set(self.user_specs)
new_specs = set()
for spec in matches:
if spec in list_to_change:
if spec not in list_to_change:
continue
try:
list_to_change.remove(spec)
self.update_stale_references(list_name)
@ -1238,11 +1239,9 @@ def remove(self, query_spec, list_name=user_speclist_name, force=False):
tty.warn(msg)
else:
if list_name == user_speclist_name:
for user_spec in matches:
self.manifest.remove_user_spec(str(user_spec))
self.manifest.remove_user_spec(str(spec))
else:
for user_spec in matches:
self.manifest.remove_definition(str(user_spec), list_name=list_name)
self.manifest.remove_definition(str(spec), list_name=list_name)
# If force, update stale concretized specs
for spec in old_specs - new_specs: