Copy modules instead of reparsing them

The Modulemd.copy() method has been available since libmodulemd 1.1
and is much faster than dumping to a string and parsing it again.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Merges: https://pagure.io/pungi/pull-request/965
This commit is contained in:
Stephen Gallagher 2018-05-30 13:41:25 -04:00 committed by Lubomír Sedlář
parent 49e8aa0c7e
commit ec96757707
2 changed files with 2 additions and 2 deletions

View File

@ -196,7 +196,7 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None)
for module_id, mmd in variant.arch_mmds[arch].items(): for module_id, mmd in variant.arch_mmds[arch].items():
# Create copy of architecture specific mmd to filter out packages # Create copy of architecture specific mmd to filter out packages
# which are not part of this particular repo. # which are not part of this particular repo.
repo_mmd = Modulemd.Module.new_from_string(mmd.dumps()) repo_mmd = mmd.copy()
repo_mmd.set_arch(tree_arch_to_yum_arch(arch)) repo_mmd.set_arch(tree_arch_to_yum_arch(arch))
artifacts = repo_mmd.get_rpm_artifacts() artifacts = repo_mmd.get_rpm_artifacts()

View File

@ -59,7 +59,7 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
for mmd in variant.mmds: for mmd in variant.mmds:
mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_stream()) mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_stream())
if mmd_id not in variant.arch_mmds[arch]: if mmd_id not in variant.arch_mmds[arch]:
arch_mmd = Modulemd.Module.new_from_string(mmd.dumps()) arch_mmd = mmd.copy()
variant.arch_mmds[arch][mmd_id] = arch_mmd variant.arch_mmds[arch][mmd_id] = arch_mmd
# Contains per-module RPMs added to variant. # Contains per-module RPMs added to variant.