summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-30 19:17:52 +0100
committerDan McGee <dan@archlinux.org>2012-01-02 19:55:55 +0100
commit819c28bf8c666a61ef3b0a016dcbd6962ecaf4e4 (patch)
tree7f6f9ba221cf7aa40daad40063a9110ddaecc20f /lib/libalpm/handle.c
parent627cf6bca88c241d7e0d5563db46f87f64792653 (diff)
downloadpacman-819c28bf8c666a61ef3b0a016dcbd6962ecaf4e4.tar.gz
pacman-819c28bf8c666a61ef3b0a016dcbd6962ecaf4e4.tar.xz
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 6518b7d5..8e2e3c73 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -34,6 +34,7 @@
#include "alpm_list.h"
#include "util.h"
#include "log.h"
+#include "delta.h"
#include "trans.h"
#include "alpm.h"
@@ -67,6 +68,8 @@ void _alpm_handle_free(alpm_handle_t *handle)
curl_easy_cleanup(handle->curl);
#endif
+ regfree(&handle->delta_regex);
+
/* free memory */
_alpm_trans_free(handle->trans);
FREE(handle->root);