EbuildMetadataPhase: avoid redundant EAPI parsing
authorZac Medico <zmedico@gentoo.org>
Sun, 16 Oct 2011 20:26:46 +0000 (13:26 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 16 Oct 2011 20:26:46 +0000 (13:26 -0700)
pym/_emerge/EbuildMetadataPhase.py
pym/portage/dbapi/porttree.py

index 2fbd29eb7134b5e73d613883e2ff930d2532b2bb..06cabe7d152a37ec3d3976592cde1200b5da6285 100644 (file)
@@ -20,7 +20,7 @@ class EbuildMetadataPhase(SubProcess):
        used to extract metadata from the ebuild.
        """
 
-       __slots__ = ("cpv", "ebuild_hash", "fd_pipes", "metadata_callback",
+       __slots__ = ("cpv", "eapi", "ebuild_hash", "fd_pipes", "metadata_callback",
                "metadata", "portdb", "repo_path", "settings") + \
                ("_raw_metadata",)
 
@@ -33,7 +33,9 @@ class EbuildMetadataPhase(SubProcess):
                settings.setcpv(self.cpv)
                ebuild_path = self.ebuild_hash.location
 
-               eapi = None
+               # the caller can pass in eapi in order to avoid
+               # redundant _parse_eapi_ebuild_head calls
+               eapi = self.eapi
                if eapi is None and \
                        'parse-eapi-ebuild-head' in settings.features:
                        eapi = portage._parse_eapi_ebuild_head(
index 13c27e9794d8922bd983fd101b8337a9429a04b5..0ade59a199319a6a6974322cac980dabf91115a0 100644 (file)
@@ -528,7 +528,7 @@ class portdbapi(dbapi):
                                mydata = self._metadata_callback(
                                        mycpv, mylocation, {'EAPI':eapi}, ebuild_hash)
                        else:
-                               proc = EbuildMetadataPhase(cpv=mycpv,
+                               proc = EbuildMetadataPhase(cpv=mycpv, eapi=eapi,
                                        ebuild_hash=ebuild_hash,
                                        metadata_callback=self._metadata_callback, portdb=self,
                                        repo_path=mylocation,