summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-26 12:02:27 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-26 12:02:27 +0300
commit1c18cb27e6bc9085e51e127732dd9e8051224ba9 (patch)
tree61fd9147b05986b36bf32a88e1756b5b15dea2ae /build
parentda20a6dbf1dfc655762440ce9784756fb4353eb8 (diff)
downloadrpm-1c18cb27e6bc9085e51e127732dd9e8051224ba9.tar.gz
rpm-1c18cb27e6bc9085e51e127732dd9e8051224ba9.tar.bz2
rpm-1c18cb27e6bc9085e51e127732dd9e8051224ba9.zip
Dont waste time with argi for rpmfc file colors
- argiAdd() isn't as costly as argvAdd(), but it still involves unnecessary reallocation on every addition as the number of files is predetermined, and each file has an associated color (whether its zero or something else)
Diffstat (limited to 'build')
-rw-r--r--build/rpmfc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/build/rpmfc.c b/build/rpmfc.c
index d4d11b85c..697d7c29d 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -48,7 +48,7 @@ struct rpmfc_s {
char ** fn; /*!< (no. files) file names */
ARGV_t *fattrs; /*!< (no. files) file attribute tokens */
- ARGI_t fcolor; /*!< (no. files) file colors */
+ rpm_color_t *fcolor;/*!< (no. files) file colors */
ARGI_t fcdictx; /*!< (no. files) file class dictionary indices */
ARGI_t fddictx; /*!< (no. files) file depends dictionary start */
ARGI_t fddictn; /*!< (no. files) file depends dictionary no. entries */
@@ -680,13 +680,12 @@ nrequires = rpmdsCount(fc->requires);
for (fx = 0; fx < fc->nfiles; fx++) {
assert(fx < fc->fcdictx->nvals);
cx = fc->fcdictx->vals[fx];
-assert(fx < fc->fcolor->nvals);
- fcolor = fc->fcolor->vals[fx];
+ fcolor = fc->fcolor[fx];
ARGV_t fattrs = fc->fattrs[fx];
fprintf(fp, "%3d %s", fx, fc->fn[fx]);
if (fcolor != RPMFC_BLACK)
- fprintf(fp, "\t0x%x", fc->fcolor->vals[fx]);
+ fprintf(fp, "\t0x%x", fc->fcolor[fx]);
else
fprintf(fp, "\t%s", rpmstrPoolStr(fc->cdict, cx));
if (fattrs) {
@@ -755,7 +754,7 @@ rpmfc rpmfcFree(rpmfc fc)
}
free(fc->fn);
free(fc->fattrs);
- argiFree(fc->fcolor);
+ free(fc->fcolor);
argiFree(fc->fcdictx);
argiFree(fc->fddictx);
argiFree(fc->fddictn);
@@ -923,6 +922,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));
+ fc->fcolor = xcalloc(fc->nfiles, sizeof(*fc->fcolor));
/* Initialize the per-file dictionary indices. */
argiAdd(&fc->fddictx, fc->nfiles-1, 0);
@@ -1004,7 +1004,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
/* Add attributes based on file type and/or path */
rpmfcAttributes(fc, ftype, s);
- argiAdd(&fc->fcolor, fc->ix, fcolor);
+ fc->fcolor[fc->ix] = fcolor;
/* Add to file class dictionary and index array */
if (fcolor != RPMFC_WHITE && (fcolor & RPMFC_INCLUDE)) {
@@ -1283,15 +1283,11 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
goto exit;
/* Add per-file colors(#files) */
- if (rpmtdFromArgi(&td, RPMTAG_FILECOLORS, fc->fcolor)) {
- rpm_color_t *fcolor;
- /* XXX Make sure only primary (i.e. Elf32/Elf64) colors are added. */
- while ((fcolor = rpmtdNextUint32(&td))) {
- *fcolor &= 0x0f;
- }
- headerPut(pkg->header, &td, HEADERPUT_DEFAULT);
- }
-
+ /* XXX Make sure only primary (i.e. Elf32/Elf64) colors are added. */
+ for (int i = 0; i < fc->nfiles; i++)
+ fc->fcolor[i] &= 0x0f;
+ headerPutUint32(pkg->header, RPMTAG_FILECOLORS, fc->fcolor, fc->nfiles);
+
/* Add classes(#classes) */
for (rpmsid id = 1; id <= rpmstrPoolNumStr(fc->cdict); id++) {
headerPutString(pkg->header, RPMTAG_CLASSDICT,