svn commit: r211389 - user/dougb/portmaster

Doug Barton dougb at FreeBSD.org
Mon Aug 16 04:22:29 UTC 2010


Author: dougb
Date: Mon Aug 16 04:22:29 2010
New Revision: 211389
URL: http://svn.freebsd.org/changeset/base/211389

Log:
  Dramatic (9-10 times) speedup in iport_from_origin() by making an
  intelligent guess about what director{y|ies] to search in based on
  the origin directory name. This algorithm only misses on 2 out of
  my 489 currently installed ports which means we're almost always
  looking in either exactly the right directory the first time, or
  at worst (such as the py-* ports) a dramatically smaller subset.

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Sun Aug 15 23:58:21 2010	(r211388)
+++ user/dougb/portmaster/portmaster	Mon Aug 16 04:22:29 2010	(r211389)
@@ -625,10 +625,14 @@ unset var newopts
 #=============== Begin functions relevant to --features and main ===============
 
 iport_from_origin () {
-	local dir
+	local sn dir
+
+	sn=${1#*/} ; sn=${sn%-*} ; sn=${sn%%[0-9]*}
 
-	if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/*/+CONTENTS 2>/dev/null`; then
-		dir=`pkg_info -q -O $1` || return 1
+	if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/${sn}*/+CONTENTS 2>/dev/null`; then
+		if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/*/+CONTENTS 2>/dev/null`; then
+			dir=`pkg_info -q -O $1` || return 1
+		fi
 	fi
 
 	# It should not happen that more than one port meets this


More information about the svn-src-user mailing list