Skip to content

Commit

Permalink
Remove/avoid redundant function calls
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Mar 26, 2024
1 parent 51f5165 commit a1d6f60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 5 additions & 7 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2668,13 +2668,11 @@ def get_loop_vars(self):
return variants.get_vars(_variants, loop_only=True)

def get_used_loop_vars(self, force_top_level=False, force_global=False):
return {
var
for var in self.get_used_vars(
force_top_level=force_top_level, force_global=force_global
)
if var in self.get_loop_vars()
}
loop_vars = self.get_loop_vars()
used_vars = self.get_used_vars(
force_top_level=force_top_level, force_global=force_global
)
return set(loop_vars).intersection(used_vars)

def get_rendered_recipe_text(
self, permit_undefined_jinja=False, extract_pattern=None
Expand Down
16 changes: 9 additions & 7 deletions conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,16 +697,18 @@ def get_package_variants(recipedir_or_metadata, config=None, variants=None):
def get_vars(variants, loop_only=False):
"""For purposes of naming/identifying, provide a way of identifying which variables contribute
to the matrix dimensionality"""
special_keys = {"pin_run_as_build", "zip_keys", "ignore_version"}
special_keys.update(set(ensure_list(variants[0].get("extend_keys"))))
first_variant, *other_variants = variants
special_keys = {
"pin_run_as_build",
"zip_keys",
"ignore_version",
*ensure_list(first_variant.get("extend_keys")),
}
loop_vars = [
k
for k in variants[0]
for k, v in first_variant.items()
if k not in special_keys
and (
not loop_only
or any(variant[k] != variants[0][k] for variant in variants[1:])
)
and (not loop_only or any(variant[k] != v for variant in other_variants))
]
return loop_vars

Expand Down

0 comments on commit a1d6f60

Please sign in to comment.