From 726e90dc2c860ee6893df29f9d8cf9c886fdd66d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 17 Jan 2007 03:57:53 +0000 Subject: Jürgen Hötzel * avoid repeated regex compilations (regex for search string do not change while scanning the package database) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove needless string duplication (regex function do not change target string nor free them) * code cleanup This patch improves search performance: bash-3.2$ time ./src/pacman/pacman.static.old -Ss "(database|web).*server" >/dev/null real 0m1.026s user 0m0.544s sys 0m0.208s bash-3.2$ time ./src/pacman/pacman.static -Ss "(database|web).*server" >/dev/null real 0m0.777s user 0m0.456s sys 0m0.128s bash-3.2$ --- lib/libalpm/util.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 1610c43f..ec4b7eef 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -54,7 +54,6 @@ #ifndef __sun__ #include #endif -#include /* pacman */ #include "log.h" @@ -619,20 +618,6 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data) } #endif -/* match a string against a regular expression */ -int _alpm_reg_match(char *string, char *pattern) -{ - int result; - regex_t reg; - - if(regcomp(®, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) { - RET_ERR(PM_ERR_INVALID_REGEX, -1); - } - result = regexec(®, string, 0, 0, 0); - regfree(®); - return(!(result)); -} - /* convert a time_t to a string - buffer MUST be large enough for * YYYYMMDDHHMMSS - 15 chars */ void _alpm_time2string(time_t t, char *buffer) -- cgit v1.2.3-24-g4f1b