pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pbulk pbulk-0.35:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/84004b1b4ba4
branches:  trunk
changeset: 547603:84004b1b4ba4
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Mon Sep 22 11:31:16 2008 +0000

description:
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:

 pkgtools/pbulk/Makefile                |   4 ++--
 pkgtools/pbulk/files/pbulk/lib/match.c |  26 +++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diffs (57 lines):

diff -r 43c20279c7be -r 84004b1b4ba4 pkgtools/pbulk/Makefile
--- a/pkgtools/pbulk/Makefile   Mon Sep 22 11:02:21 2008 +0000
+++ b/pkgtools/pbulk/Makefile   Mon Sep 22 11:31:16 2008 +0000
@@ -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 -r 43c20279c7be -r 84004b1b4ba4 pkgtools/pbulk/files/pbulk/lib/match.c
--- a/pkgtools/pbulk/files/pbulk/lib/match.c    Mon Sep 22 11:02:21 2008 +0000
+++ b/pkgtools/pbulk/files/pbulk/lib/match.c    Mon Sep 22 11:31:16 2008 +0000
@@ -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 @@
 }
 
 /*
+ * 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);



Home | Main Index | Thread Index | Old Index