diff options
author | joerg <joerg@pkgsrc.org> | 2008-09-22 11:31:16 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2008-09-22 11:31:16 +0000 |
commit | 19802ddd6ddd2aada54866f2a29a37e9ef9e2b1e (patch) | |
tree | 3cc28600b6d9cc36fd8f5b073012ac84dccd3ee9 /pkgtools/pbulk | |
parent | adb134c75bab792ed2dc2b74c2579c7e830a0b1f (diff) | |
download | pkgsrc-19802ddd6ddd2aada54866f2a29a37e9ef9e2b1e.tar.gz |
pbulk-0.35:
Sync Dewey with pkg_install(-renovation) and add a fast check if a
pattern could ever match. This reduces the time for pbulk-resolve on a
full tree on my laptop from 12.9s to 5.3s.
Diffstat (limited to 'pkgtools/pbulk')
-rw-r--r-- | pkgtools/pbulk/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pbulk/files/pbulk/lib/match.c | 26 |
2 files changed, 27 insertions, 3 deletions
diff --git a/pkgtools/pbulk/Makefile b/pkgtools/pbulk/Makefile index 68d68904f36..f0819fa5441 100644 --- a/pkgtools/pbulk/Makefile +++ b/pkgtools/pbulk/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.46 2008/09/16 18:21:30 joerg Exp $ +# $NetBSD: Makefile,v 1.47 2008/09/22 11:31:16 joerg Exp $ -DISTNAME= pbulk-0.34 +DISTNAME= pbulk-0.35 CATEGORIES= pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pbulk/files/pbulk/lib/match.c b/pkgtools/pbulk/files/pbulk/lib/match.c index fdd8af26a77..e68308443b6 100644 --- a/pkgtools/pbulk/files/pbulk/lib/match.c +++ b/pkgtools/pbulk/files/pbulk/lib/match.c @@ -1,4 +1,4 @@ -/* $NetBSD: match.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */ +/* $NetBSD: match.c,v 1.3 2008/09/22 11:31:16 joerg Exp $ */ /* * Copyright © 2002 Alistair G. Crooks. All rights reserved. @@ -456,11 +456,35 @@ simple_match(const char *pattern, const char *pkg) } /* + * Performs a fast check if pattern can ever match pkg. + * Returns 1 if a match is possible and 0 otherwise. + */ +static int +quick_pkg_match(const char *pattern, const char *pkg) +{ +#define simple(x) (isalnum((unsigned char)(x)) || (x) == '-') + if (!simple(pattern[0])) + return 1; + if (pattern[0] != pkg[0]) + return 0; + + if (!simple(pattern[1])) + return 1; + if (pattern[1] != pkg[1]) + return 0; + return 1; +#undef simple +} + +/* * Match pkg against pattern, return 1 if matching, 0 else */ int pkg_match(const char *pattern, const char *pkg) { + if (quick_pkg_match(pattern, pkg) == 0) + return 0; + if (strchr(pattern, '{') != (char *) NULL) { /* emulate csh-type alternates */ return alternate_match(pattern, pkg); |