From 6d3af291c5471664ffc17b203cbf696de8395570 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Thu, 4 Jan 2001 22:12:42 +0000 Subject: [PATCH] The ports collections grows and perl5 seems to become slower ... Small optimization to make ports.cgi one CPU second faster. --- en/cgi/ports.cgi | 39 ++++++++++++++++++++++++++++----------- en/ports/Makefile.inc | 4 ++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/en/cgi/ports.cgi b/en/cgi/ports.cgi index 4b78010a1e..22ea3a2a4d 100755 --- a/en/cgi/ports.cgi +++ b/en/cgi/ports.cgi @@ -24,7 +24,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: www/en/cgi/ports.cgi,v 1.48 2000/11/07 21:43:02 wosch Exp $ +# $FreeBSD: www/en/cgi/ports.cgi,v 1.49 2000/12/28 12:33:00 wosch Exp $ # # ports.cgi - search engine for FreeBSD ports # o search for a port by name or description @@ -249,18 +249,35 @@ sub readindex { sub readcoll { local(@co) = ('co', '-p', 'ports/INDEX'); - open(C, "-|") || exec (@cvscmd, @co); - local(@a, @b, %key); - while() { - chop; + local($file) = '../ports/categories'; - @a = split('\|'); - @b = split(/\s+/, $a[6]); + if (-r $file && open(C, $file)) { + while() { + chop; - foreach (@b) { - if (!defined($key{$_})) { - $key{$_} = 1; + if (/^\s*\"([^\"]+)\"\s*,/) { #" + @b = split(/\s+/, $1); + foreach (@b) { + if (!defined($key{$_})) { + $key{$_} = 1; + } + } + } + } + } else { + open(C, "-|") || exec (@cvscmd, @co); + + while() { + chop; + + @a = split('\|'); + @b = split(/\s+/, $a[6]); + + foreach (@b) { + if (!defined($key{$_})) { + $key{$_} = 1; + } } } } @@ -537,7 +554,7 @@ sub footer { © 1996-2000 by Wolfram Schneider. All rights reserved.
}; - #print q{$FreeBSD: www/en/cgi/ports.cgi,v 1.48 2000/11/07 21:43:02 wosch Exp $} . "
\n"; + #print q{$FreeBSD: www/en/cgi/ports.cgi,v 1.49 2000/12/28 12:33:00 wosch Exp $} . "
\n"; print qq{Please direct questions about this service to $mailto
\n}; print qq{General questions about FreeBSD ports should be sent to } . diff --git a/en/ports/Makefile.inc b/en/ports/Makefile.inc index 1d98fc2fb2..58a5c5633c 100644 --- a/en/ports/Makefile.inc +++ b/en/ports/Makefile.inc @@ -1,4 +1,4 @@ -# $FreeBSD: www/en/ports/Makefile.inc,v 1.3 2000/04/20 16:42:04 phantom Exp $ +# $FreeBSD: www/en/ports/Makefile.inc,v 1.4 2001/01/01 12:33:23 kuriyama Exp $ PORTINDEX= ${PERL} ${.CURDIR}/portindex INDEX= INDEX @@ -13,5 +13,5 @@ CLEANFILES+= Makefile.gen cvsindex= $${CVSROOT}/${PINDEX},v -_ALLINSTALL= packages.exists ${INDEX} +_ALLINSTALL= packages.exists ${INDEX} categories