From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EBB6B138ACE for ; Sun, 7 Dec 2014 23:14:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 08B0FE0C6B; Sun, 7 Dec 2014 23:14:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 86C7FE0C6B for ; Sun, 7 Dec 2014 23:14:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BCC00340516 for ; Sun, 7 Dec 2014 23:14:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C8E8FBD5A for ; Sun, 7 Dec 2014 23:14:02 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1417993848.646b671d4afb92e0bb81664568544e01e8456dc2.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/search.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 646b671d4afb92e0bb81664568544e01e8456dc2 X-VCS-Branch: master Date: Sun, 7 Dec 2014 23:14:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 7ccf2056-80d1-4615-80ae-22378ab47df1 X-Archives-Hash: 3048e3cc21ed556d455d18525924ade5 commit: 646b671d4afb92e0bb81664568544e01e8456dc2 Author: Zac Medico gentoo org> AuthorDate: Fri Nov 7 07:58:19 2014 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Dec 7 23:10:48 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=646b671d search: optimize desc search with _first_cp --- pym/_emerge/search.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py index 4b1833a..90dbcec 100644 --- a/pym/_emerge/search.py +++ b/pym/_emerge/search.py @@ -123,6 +123,23 @@ class search(object): cpv=cpv, built=built, installed=installed, metadata=metadata).visible + def _first_cp(self, cp): + + for db in self._dbs: + if hasattr(db, "cp_list"): + matches = db.cp_list(cp) + if matches: + return matches[-1] + else: + matches = db.match(cp) + + for cpv in matches: + if cpv.cp == cp: + return cpv + + return None + + def _xmatch(self, level, atom): """ This method does not expand old-style virtuals because it @@ -230,13 +247,12 @@ class search(object): if self.searchre.search(match_string): yield ("pkg", package) elif self.searchdesc: # DESCRIPTION searching - # Use match-all to avoid an expensive visibility check, + # Use _first_cp to avoid an expensive visibility check, # since the visibility check can be avoided entirely # when the DESCRIPTION does not match. - full_package = self._xmatch("match-all", package) + full_package = self._first_cp(package) if not full_package: continue - full_package = full_package[-1] try: full_desc = self._aux_get( full_package, ["DESCRIPTION"])[0]