From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-571369-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 74D76198005
	for <garchives@archives.gentoo.org>; Mon, 18 Mar 2013 19:39:24 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 564BDE002B;
	Mon, 18 Mar 2013 19:39:21 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E0526E002B
	for <gentoo-commits@lists.gentoo.org>; Mon, 18 Mar 2013 19:39:20 +0000 (UTC)
Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id CD48633DB2F
	for <gentoo-commits@lists.gentoo.org>; Mon, 18 Mar 2013 19:39:19 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id 718E8E4073
	for <gentoo-commits@lists.gentoo.org>; Mon, 18 Mar 2013 19:39:18 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
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" <zmedico@gentoo.org>
Message-ID: <1363635542.0fa5cbb1e1eb0da33ba6bb7bc21285c0e5ff489c.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/portageq
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: 0fa5cbb1e1eb0da33ba6bb7bc21285c0e5ff489c
X-VCS-Branch: master
Date: Mon, 18 Mar 2013 19:39:18 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 9662fd63-bfcf-4f3b-8a37-b7760fdb7a47
X-Archives-Hash: e7329eeab38885d75a20e4d3f419421d

commit:     0fa5cbb1e1eb0da33ba6bb7bc21285c0e5ff489c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 18 19:39:02 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Mar 18 19:39:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0fa5cbb1

portageq: optimize pquery --no-version

---
 bin/portageq |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index f76a967..b3c872d 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -996,6 +996,7 @@ def pquery(parser, pquery_option_groups, opts, args):
 		else:
 			names = sorted(set(names))
 
+	no_version = opts.no_version
 	categories.sort()
 
 	for category in categories:
@@ -1044,6 +1045,8 @@ def pquery(parser, pquery_option_groups, opts, args):
 									continue
 							matches.append(cpv)
 							break
+						if no_version and matches:
+							break
 				elif opts.no_filters:
 					matches.extend(cpv_list)
 				else:
@@ -1055,15 +1058,20 @@ def pquery(parser, pquery_option_groups, opts, args):
 						else:
 							if pkg.visible:
 								matches.append(cpv)
+								if no_version:
+									break
+
+				if no_version and matches:
+					break
 
 			if not matches:
 				continue
 
-			if opts.no_version:
+			if no_version:
 				writemsg_stdout("%s\n" % (cp,), noiselevel=-1)
 			else:
-				matches = sorted(set(matches),
-					key=portage.versions.cpv_sort_key())
+				matches = list(set(matches))
+				portdb._cpv_sort_ascending(matches)
 				for cpv in matches:
 					writemsg_stdout("%s\n" % (cpv,), noiselevel=-1)