summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-26 11:31:41 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-26 11:58:29 +0300
commitda20a6dbf1dfc655762440ce9784756fb4353eb8 (patch)
tree2e5502691f4118309d86c21e8086b64bf819d89e /build
parentcb112b67450398aa0981b4055fc66e9972b91eff (diff)
downloadlibrpm-tizen-da20a6dbf1dfc655762440ce9784756fb4353eb8.tar.gz
librpm-tizen-da20a6dbf1dfc655762440ce9784756fb4353eb8.tar.bz2
librpm-tizen-da20a6dbf1dfc655762440ce9784756fb4353eb8.zip
Dont waste time with argv for rpmfc file names
- argvAdd() gets more and more costly as the number of files increase, use a plain old string array where one is called for: the size is predetermined (from another argv) and we're just copying the strings for internal storage here. We do need to pay a little bit more attention to details now though.
Diffstat (limited to 'build')
-rw-r--r--build/rpmfc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/build/rpmfc.c b/build/rpmfc.c
index cd77301d9..d4d11b85c 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -46,7 +46,7 @@ struct rpmfc_s {
rpmfcAttr *atypes; /*!< known file attribute types */
- ARGV_t fn; /*!< (no. files) file names */
+ char ** fn; /*!< (no. files) file names */
ARGV_t *fattrs; /*!< (no. files) file attribute tokens */
ARGI_t fcolor; /*!< (no. files) file colors */
ARGI_t fcdictx; /*!< (no. files) file class dictionary indices */
@@ -749,9 +749,11 @@ rpmfc rpmfcFree(rpmfc fc)
rpmfcAttrFree(*attr);
free(fc->atypes);
free(fc->buildRoot);
- argvFree(fc->fn);
- for (int i = 0; i < fc->nfiles; i++)
+ for (int i = 0; i < fc->nfiles; i++) {
+ free(fc->fn[i]);
argvFree(fc->fattrs[i]);
+ }
+ free(fc->fn);
free(fc->fattrs);
argiFree(fc->fcolor);
argiFree(fc->fcdictx);
@@ -811,7 +813,7 @@ rpmRC rpmfcApply(rpmfc fc)
int ix;
/* Generate package and per-file dependencies. */
- for (fc->ix = 0; fc->fn != NULL && fc->fn[fc->ix] != NULL; fc->ix++) {
+ for (fc->ix = 0; fc->ix < fc->nfiles && fc->fn[fc->ix] != NULL; fc->ix++) {
for (ARGV_t fattr = fc->fattrs[fc->ix]; fattr && *fattr; fattr++) {
rpmfcHelperProvides(fc, *fattr);
rpmfcHelperRequires(fc, *fattr);
@@ -919,6 +921,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
}
fc->nfiles = argvCount(argv);
+ fc->fn = xcalloc(fc->nfiles, sizeof(*fc->fn));
fc->fattrs = xcalloc(fc->nfiles, sizeof(*fc->fattrs));
/* Initialize the per-file dictionary indices. */
@@ -993,7 +996,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
rpmlog(RPMLOG_DEBUG, "%s: %s\n", s, ftype);
/* Save the path. */
- argvAdd(&fc->fn, s);
+ fc->fn[fc->ix] = xstrdup(s);
/* Add (filtered) file coloring */
fcolor |= rpmfcColor(ftype);