From 819c28bf8c666a61ef3b0a016dcbd6962ecaf4e4 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 30 Dec 2011 12:17:52 -0600 Subject: Only compile delta regex once This reduces the number of regcomp() calls when parsing delta entries in the database from once per entry to once for the entire context handle by storing the compiled regex data on the handle itself. Just as we do with the cURL handle, we initialize it the first time it is needed and free it when releasing the handle. A few other small tweaks to the parsing function also take place, including using the stack to store the transient and short file size string while parsing it. When parsing a sync database with 1378 delta entries, this reduces the time of a `pacman -Sl deltas` operation by 50% from 0.22s to 0.12s. Signed-off-by: Dan McGee --- lib/libalpm/handle.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/libalpm/handle.h') diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 1f147d6e..a64c5c9e 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -22,6 +22,7 @@ #include #include +#include #include "alpm_list.h" #include "alpm.h" @@ -94,6 +95,10 @@ struct __alpm_handle_t { /* error code */ alpm_errno_t pm_errno; + + /* for delta parsing efficiency */ + int delta_regex_compiled; + regex_t delta_regex; }; alpm_handle_t *_alpm_handle_new(void); -- cgit v1.2.3-24-g4f1b