From: Michael Schroeder Date: Wed, 25 Sep 2024 11:52:40 +0000 (+0200) Subject: Init the whatprovides of new ids to an empty list for lazy file provides X-Git-Tag: 0.7.31~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=081580de9f964aae61d25e1787c37c7ab8b4fa69;p=thirdparty%2Flibsolv.git Init the whatprovides of new ids to an empty list for lazy file provides Otherwise finding the provides will always search the file list. --- diff --git a/src/poolid.c b/src/poolid.c index c73d5b44..bda648fc 100644 --- a/src/poolid.c +++ b/src/poolid.c @@ -20,6 +20,18 @@ #include "poolid_private.h" #include "util.h" +static inline void +grow_whatprovides(Pool *pool, Id id) +{ + if ((id & WHATPROVIDES_BLOCK) == 0) + { + /* grow whatprovides array */ + pool->whatprovides = solv_realloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); + memset(pool->whatprovides + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset)); + } + if (pool->addedfileprovides == 1) + pool->whatprovides[id] = 1; +} /* intern string into pool, return id */ @@ -28,12 +40,8 @@ pool_str2id(Pool *pool, const char *str, int create) { int oldnstrings = pool->ss.nstrings; Id id = stringpool_str2id(&pool->ss, str, create); - if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0) - { - /* grow whatprovides array */ - pool->whatprovides = solv_realloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); - memset(pool->whatprovides + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset)); - } + if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings) + grow_whatprovides(pool, id); return id; } @@ -42,12 +50,8 @@ pool_strn2id(Pool *pool, const char *str, unsigned int len, int create) { int oldnstrings = pool->ss.nstrings; Id id = stringpool_strn2id(&pool->ss, str, len, create); - if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0) - { - /* grow whatprovides array */ - pool->whatprovides = solv_realloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); - memset(pool->whatprovides + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset)); - } + if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings) + grow_whatprovides(pool, id); return id; }