Skip to content

Commit

Permalink
Reduce unnecessary temporary list creation
Browse files Browse the repository at this point in the history
postfix temporary lists are hard to read and slow the code down (not
that would matter). Plus, it produces headaches.
  • Loading branch information
dirkmueller committed Nov 26, 2024
1 parent 6e39a80 commit 40d2136
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
25 changes: 12 additions & 13 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,18 +1284,19 @@ def build_tags(self) -> list[str]:
if self.stability_tag:
ver_labels = [self.stability_tag] + ver_labels
for ver_label in ver_labels:
tags += [
tags.append(
f"{self.registry_prefix}/{name}:{ver_label}-{self._release_suffix}"
]
tags += [f"{self.registry_prefix}/{name}:{ver_label}"]
)
tags.append(f"{self.registry_prefix}/{name}:{ver_label}")
additional_ver_labels: list[str] = self.additional_versions
if self._version_variant != self._tag_variant:
additional_ver_labels = [self._tag_variant] + additional_ver_labels
for ver_label in additional_ver_labels:
tags += [f"{self.registry_prefix}/{name}:{ver_label}"]

tags.extend(
f"{self.registry_prefix}/{name}:{ver_label}"
for ver_label in additional_ver_labels
)
if self.is_latest:
tags += [f"{self.registry_prefix}/{name}:latest"]
tags.append(f"{self.registry_prefix}/{name}:latest")
return tags

@property
Expand Down Expand Up @@ -1396,12 +1397,10 @@ def build_tags(self) -> list[str]:
tags: list[str] = []

for name in [self.name] + self.additional_names:
tags += [
f"{self.registry_prefix}/bci-{name}:{self.image_ref_name}",
f"{self.registry_prefix}/bci-{name}:%OS_VERSION_ID_SP%",
] + (
[f"{self.registry_prefix}/bci-{name}:latest"] if self.is_latest else []
)
tags.append(f"{self.registry_prefix}/bci-{name}:{self.image_ref_name}")
tags.append(f"{self.registry_prefix}/bci-{name}:%OS_VERSION_ID_SP%")
if self.is_latest:
tags.append(f"{self.registry_prefix}/bci-{name}:latest")
return tags

@property
Expand Down
8 changes: 4 additions & 4 deletions src/bci_build/package/basecontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ def _get_minimal_kwargs(os_version: OsVersion):
if os_version in (OsVersion.SP6,):
package_list.append(Package("libpcre1", pkg_type=PackageType.DELETE))

package_list += [
package_list.extend(
Package(name, pkg_type=PackageType.BOOTSTRAP)
for name in os_version.release_package_names
]
)
if os_version in (OsVersion.TUMBLEWEED, OsVersion.SLE16_0):
package_list.append(Package("rpm", pkg_type=PackageType.BOOTSTRAP))
else:
# in SLE15, rpm still depends on Perl.
package_list += [
package_list.extend(
Package(name, pkg_type=PackageType.BOOTSTRAP)
for name in ("rpm-ndb", "perl-base")
]
)

kwargs = {
"from_image": f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
Expand Down

0 comments on commit 40d2136

Please sign in to comment.