From 6ae8f07ed6175e3a2f8c02517cdc20a33fc90abe Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Wed, 25 May 2011 12:16:35 +0000 Subject: memoize handle_config; is not a slow routine per se, but we spend a lot of time in it, so cache the return values. The most gain is from configure scripts/build commands which query several modules at the same time. this results in as much as a 40% speedup for those pkg-config invocations. tested in a bulk/ok landry@ --- usr.bin/pkg-config/pkg-config | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/pkg-config/pkg-config b/usr.bin/pkg-config/pkg-config index cb2bfcb8a04..d107b6d6408 100644 --- a/usr.bin/pkg-config/pkg-config +++ b/usr.bin/pkg-config/pkg-config @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: pkg-config,v 1.43 2011/05/18 11:12:13 jasper Exp $ +# $OpenBSD: pkg-config,v 1.44 2011/05/25 12:16:34 jasper Exp $ # $CSK: pkgconfig.pl,v 1.39 2006/11/27 16:26:20 ckuethe Exp $ # Copyright (c) 2006 Chris Kuethe @@ -21,6 +21,7 @@ use strict; use warnings; use Getopt::Long; use File::Basename; +use Memoize; use OpenBSD::PkgConfig; my @PKGPATH = qw(/usr/lib/pkgconfig /usr/local/lib/pkgconfig /usr/X11R6/lib/pkgconfig); @@ -104,6 +105,12 @@ GetOptions( 'debug' => \$D, 'define-variable=s' => $variables, ); +# handle_config() is not a slow routine per se, but we spend +# a lot of time in it, so cache the return values. The most gain +# is from configure scripts/build commands which query several modules +# at the same time. +memoize('handle_config'); + # Initial value of printerr depends on the options... if (!defined $mode{printerr}) { if (defined $mode{libs} || defined $mode{cflags} -- cgit v1.2.3