Skip to content

Commit 237946c

Browse files
committed
Improve main schema generation
Now less complex and may result in a smaller solv file,
1 parent d9ebbcf commit 237946c

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

src/repo_write.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ repowriter_write(Repowriter *writer, FILE *fp)
11711171
Stringpool *spool;
11721172
Dirpool *dirpool;
11731173

1174-
Id mainschema;
1174+
Id mainschema, *mainschemakeys;
11751175

11761176
struct extdata *xd;
11771177

@@ -1511,7 +1511,8 @@ for (i = 1; i < target.nkeys; i++)
15111511
target.keys[keymap[REPOSITORY_SOLVABLES]].size++;
15121512
}
15131513
*sp = 0;
1514-
mainschema = repodata_schema2id(cbdata.target, cbdata.schema + 1, 1);
1514+
/* stash away main schema (including terminating zero) */
1515+
mainschemakeys = solv_memdup2(cbdata.schema + 1, sp - cbdata.schema, sizeof(Id));
15151516

15161517
/* collect data for all solvables */
15171518
solvschemata = solv_calloc(repo->nsolvables, sizeof(Id)); /* allocate upper bound */
@@ -1551,22 +1552,13 @@ for (i = 1; i < target.nkeys; i++)
15511552

15521553
if (repo->nsolvables && !anysolvableused)
15531554
{
1554-
/* strip off solvable from the main schema */
1555-
target.keys[keymap[REPOSITORY_SOLVABLES]].size = 0;
1556-
sp = cbdata.schema + 1;
1557-
for (i = 0; target.schemadata[target.schemata[mainschema] + i]; i++)
1558-
{
1559-
*sp = target.schemadata[target.schemata[mainschema] + i];
1560-
if (*sp != keymap[REPOSITORY_SOLVABLES])
1561-
sp++;
1562-
}
1563-
assert(target.schemadatalen == target.schemata[mainschema] + i + 1);
1564-
*sp = 0;
1565-
target.schemadatalen = target.schemata[mainschema];
1566-
target.nschemata--;
1567-
repodata_free_schemahash(&target);
1568-
mainschema = repodata_schema2id(cbdata.target, cbdata.schema + 1, 1);
1555+
/* strip off REPOSITORY_SOLVABLES from the main schema */
1556+
for (sp = mainschemakeys; *sp; sp++)
1557+
;
1558+
sp[-1] = 0; /* strip last entry */
15691559
}
1560+
mainschema = repodata_schema2id(cbdata.target, mainschemakeys, 1);
1561+
mainschemakeys = solv_free(mainschemakeys);
15701562

15711563
/********************************************************************/
15721564

0 commit comments

Comments
 (0)