From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R7Yd9-0004N9-0z for garchives@archives.gentoo.org; Sat, 24 Sep 2011 20:15:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B899321C070; Sat, 24 Sep 2011 20:15:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 759AD21C070 for ; Sat, 24 Sep 2011 20:15:14 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B5C661B4008 for ; Sat, 24 Sep 2011 20:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D388B80042 for ; Sat, 24 Sep 2011 20:15:12 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <97d2dac2cb7ee7ad33a31786eed74e1c204576dd.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/porttree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 97d2dac2cb7ee7ad33a31786eed74e1c204576dd Date: Sat, 24 Sep 2011 20:15:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 335c24f93e8e64b497ae527b6f11e6ab commit: 97d2dac2cb7ee7ad33a31786eed74e1c204576dd Author: Zac Medico gentoo org> AuthorDate: Sat Sep 24 20:14:59 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Sep 24 20:14:59 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D97d2dac2 portdbapi: tweak single-tree optimization This optimizes aux_get and cp_list for cases where we only have a single tree, which is common for repoman and ebuild(1). --- pym/portage/dbapi/porttree.py | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.p= y index d3cca00..42e5ca1 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -465,9 +465,16 @@ class portdbapi(dbapi): if mytree is None: raise KeyError(myrepo) =20 - if not mytree: + if mytree is not None and len(self.porttrees) =3D=3D 1 \ + and mytree =3D=3D self.porttrees[0]: + # mytree matches our only tree, so it's safe to + # ignore mytree and cache the result + mytree =3D None + myrepo =3D None + + if mytree is None: cache_me =3D True - if not mytree and not self._known_keys.intersection( + if mytree is None and not self._known_keys.intersection( mylist).difference(self._aux_cache_keys): aux_cache =3D self._aux_cache.get(mycpv) if aux_cache is not None: @@ -730,6 +737,14 @@ class portdbapi(dbapi): return l =20 def cp_list(self, mycp, use_cache=3D1, mytree=3DNone): + + if self.frozen and mytree is not None \ + and len(self.porttrees) =3D=3D 1 \ + and mytree =3D=3D self.porttrees[0]: + # mytree matches our only tree, so it's safe to + # ignore mytree and cache the result + mytree =3D None + if self.frozen and mytree is None: cachelist =3D self.xcache["cp-list"].get(mycp) if cachelist is not None: @@ -857,7 +872,7 @@ class portdbapi(dbapi): # match *all* visible *and* masked packages if mydep =3D=3D mykey: myval =3D self.cp_list(mykey, mytree=3Dmytree) - elif mydep.repo is not None or len(self.porttrees) =3D=3D 1: + elif mydep.repo is not None: myval =3D list(self._iter_match(mydep, self.cp_list(mykey, mytree=3Dmytree))) else: @@ -886,7 +901,7 @@ class portdbapi(dbapi): if mydep =3D=3D mykey: for myval in self.cp_list(mykey, mytree=3Dmytree): break - elif mydep.repo is not None or len(self.porttrees) =3D=3D 1: + elif mydep.repo is not None: for myval in self._iter_match(mydep, self.cp_list(mykey, mytree=3Dmytree)): break @@ -917,7 +932,7 @@ class portdbapi(dbapi): else: iterfunc =3D reversed =20 - if mydep.repo is not None or len(self.porttrees) =3D=3D 1: + if mydep.repo is not None: repos =3D [mydep.repo] else: # We iterate over self.porttrees, since it's common to @@ -1010,9 +1025,7 @@ class portdbapi(dbapi): aux_keys =3D list(self._aux_cache_keys) metadata =3D {} =20 - if len(self.porttrees) =3D=3D 1: - repos =3D [None] - elif myrepo is not None: + if myrepo is not None: repos =3D [myrepo] else: # We iterate over self.porttrees, since it's common to