]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
cleanup hash code, it makes no sense to have an extra type for the mask
authorMichael Schroeder <mls@suse.de>
Fri, 5 Apr 2013 15:00:30 +0000 (17:00 +0200)
committerMichael Schroeder <mls@suse.de>
Fri, 5 Apr 2013 15:00:30 +0000 (17:00 +0200)
ext/pool_fileconflicts.c
ext/repo_arch.c
ext/repo_mdk.c
ext/repo_susetags.c
src/hash.h
src/pool.h
src/poolid.c
src/repo.h
src/repo_solv.c
src/strpool.c
src/strpool.h

index 806cdb14b8bd2addd22806ba72b65ecf23dd70f4..bfc766146fa56628313a1c68ff9ba3d5c8d01156 100644 (file)
@@ -21,12 +21,12 @@ struct cbdata {
   Queue lookat;
   Queue lookat_dir;
 
-  Hashval *cflmap;
-  Hashmask cflmapn;
+  Hashtable cflmap;
+  Hashval cflmapn;
   unsigned int cflmapused;
 
-  Hashval *dirmap;
-  Hashmask dirmapn;
+  Hashtable dirmap;
+  Hashval dirmapn;
   unsigned int dirmapused;
   int dirconflicts;
 
@@ -42,13 +42,13 @@ struct cbdata {
 
 #define FILESSPACE_BLOCK 255
 
-static Hashval *
-doublehash(Hashval *map, Hashmask *mapnp)
+static Hashtable
+growhash(Hashtable map, Hashval *mapnp)
 {
-  Hashmask mapn = *mapnp;
-  Hashmask i, hx, qx, h, hh;
-  Hashmask nn = (mapn + 1) * 2 - 1;
-  Hashmask *m;
+  Hashval mapn = *mapnp;
+  Hashval i, hx, qx, h, hh;
+  Hashval nn = (mapn + 1) * 2 - 1;
+  Hashtable m;
 
   m = solv_calloc(nn + 1, 2 * sizeof(Id));
   for (i = 0; i <= mapn; i++)
@@ -77,7 +77,7 @@ static void
 finddirs_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
 {
   struct cbdata *cbdata = cbdatav;
-  Hashmask h, hh, hx, qx;
+  Hashval h, hh, hx, qx;
   Hashval idx = cbdata->idx;
 
   hx = strhash(fn);
@@ -103,7 +103,7 @@ finddirs_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
       cbdata->dirmap[2 * h + 1] = idx;
       cbdata->dirmapused++;
       if (cbdata->dirmapused * 2 > cbdata->dirmapn)
-       cbdata->dirmap = doublehash(cbdata->dirmap, &cbdata->dirmapn);
+       cbdata->dirmap = growhash(cbdata->dirmap, &cbdata->dirmapn);
       return;
     }
   if (cbdata->dirmap[2 * h + 1] == idx)
@@ -119,9 +119,9 @@ finddirs_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
 }
 
 static inline int
-isindirmap(struct cbdata *cbdata, Hashmask hx)
+isindirmap(struct cbdata *cbdata, Hashval hx)
 {
-  Hashmask h, hh, qx;
+  Hashval h, hh, qx;
 
   h = hx & cbdata->dirmapn;
   hh = HASHCHAIN_START;
@@ -143,7 +143,7 @@ findfileconflicts_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
   int isdir = S_ISDIR(fmode);
   char *dp;
   Hashval idx, qidx;
-  Hashmask qx, h, hx, hh, dhx;
+  Hashval qx, h, hx, hh, dhx;
 
   idx = cbdata->idx;
 
@@ -182,7 +182,7 @@ findfileconflicts_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
       cbdata->cflmap[2 * h + 1] = (isdir ? ~idx : idx);
       cbdata->cflmapused++;
       if (cbdata->cflmapused * 2 > cbdata->cflmapn)
-       cbdata->cflmap = doublehash(cbdata->cflmap, &cbdata->cflmapn);
+       cbdata->cflmap = growhash(cbdata->cflmap, &cbdata->cflmapn);
       return;
     }
   qidx = cbdata->cflmap[2 * h + 1];
@@ -317,7 +317,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
         idxmapset++;
     }
 
-  POOL_DEBUG(SOLV_DEBUG_STATS, "dirmap size: %d used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "dirmap size: %d, used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
   POOL_DEBUG(SOLV_DEBUG_STATS, "dirmap memory usage: %d K\n", (cbdata.dirmapn + 1) * 2 * (int)sizeof(Id) / 1024);
   POOL_DEBUG(SOLV_DEBUG_STATS, "dirmap creation took %d ms\n", solv_timems(now));
   POOL_DEBUG(SOLV_DEBUG_STATS, "dir conflicts found: %d, idxmap %d of %d\n", cbdata.dirconflicts, idxmapset, pkgs->count);
@@ -343,7 +343,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
         rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_NOGHOSTS, findfileconflicts_cb, &cbdata);
     }
 
-  POOL_DEBUG(SOLV_DEBUG_STATS, "filemap size: %d used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "filemap size: %d, used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
   POOL_DEBUG(SOLV_DEBUG_STATS, "filemap memory usage: %d K\n", (cbdata.cflmapn + 1) * 2 * (int)sizeof(Id) / 1024);
   POOL_DEBUG(SOLV_DEBUG_STATS, "filemap creation took %d ms\n", solv_timems(now));
 
index 835899ee2ff5d290815eab1d6a6745cd14f73f0c..e9d12a7499a436235ed25bdbc6368c2f4675342b 100644 (file)
@@ -500,9 +500,9 @@ static char *getsentrynl(struct tarhead *th, char *s, int size)
 }
 
 static Hashtable
-joinhash_init(Repo *repo, Hashmask *hmp)
+joinhash_init(Repo *repo, Hashval *hmp)
 {
-  Hashmask hm = mkmask(repo->nsolvables);
+  Hashval hm = mkmask(repo->nsolvables);
   Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
   Hashval h, hh;
   Solvable *s;
@@ -521,7 +521,7 @@ joinhash_init(Repo *repo, Hashmask *hmp)
 }
 
 static Solvable *
-joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, const char *fn)
+joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, const char *fn)
 {
   const char *p;
   Id name, evr;
@@ -748,7 +748,7 @@ repo_add_arch_repo(Repo *repo, FILE *fp, int flags)
   int lastdnlen = 0;
   Solvable *s = 0;
   Hashtable joinhash = 0;
-  Hashmask joinhashmask = 0;
+  Hashval joinhashmask = 0;
 
   data = repo_add_repodata(repo, flags);
 
index 82d326541802b97e4f522ec0811dd97ed03692bd..bdd7f4025764d61914219f68bf4dd1f8ba52feca 100644 (file)
@@ -287,7 +287,7 @@ struct parsedata {
   enum state sbtab[NUMSTATES];
   Solvable *solvable;
   Hashtable joinhash;
-  Hashmask joinhashmask;
+  Hashval joinhashmask;
 };
 
 static inline const char *
@@ -302,9 +302,9 @@ find_attr(const char *txt, const char **atts)
 }
 
 static Hashtable
-joinhash_init(Repo *repo, Hashmask *hmp)
+joinhash_init(Repo *repo, Hashval *hmp)
 {
-  Hashmask hm = mkmask(repo->nsolvables);
+  Hashval hm = mkmask(repo->nsolvables);
   Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
   Hashval h, hh;
   Solvable *s;
@@ -323,7 +323,7 @@ joinhash_init(Repo *repo, Hashmask *hmp)
 }
 
 static Solvable *
-joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, const char *fn, const char *distepoch)
+joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, const char *fn, const char *distepoch)
 {
   Hashval h, hh;
   const char *p, *vrstart, *vrend;
index c4272009a2f0c6a87191511fbc7c912b598558fa..4f0232a395d53af474c4680896a356ba5fb05a5e 100644 (file)
@@ -385,9 +385,9 @@ finish_solvable(struct parsedata *pd, Solvable *s, Offset freshens)
 }
 
 static Hashtable
-joinhash_init(Repo *repo, Hashmask *hmp)
+joinhash_init(Repo *repo, Hashval *hmp)
 {
-  Hashmask hm = mkmask(repo->nsolvables);
+  Hashval hm = mkmask(repo->nsolvables);
   Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
   Hashval h, hh;
   Solvable *s;
@@ -406,7 +406,7 @@ joinhash_init(Repo *repo, Hashmask *hmp)
 }
 
 static Solvable *
-joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch, Id start)
+joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, Id name, Id evr, Id arch, Id start)
 {
   Hashval h, hh;
 
@@ -478,7 +478,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
   Repodata *data = 0;
   Id handle = 0;
   Hashtable joinhash = 0;
-  Hashmask joinhashm = 0;
+  Hashval joinhashm = 0;
   int createdpkgs = 0;
 
   if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
index b3cfbde4a1f262c048aef0a2c0b83f64e52f4808..1d3222bce05aaf147818469ae121f2b59431dfd2 100644 (file)
@@ -21,9 +21,6 @@ extern "C" {
 
 /* value of a hash */
 typedef unsigned int Hashval;
-/* mask for hash, used as modulo operator to ensure 'wrapping' of hash
-   values -> hash table */
-typedef unsigned int Hashmask;
 
 /* inside the hash table, Ids are stored. Hash maps: string -> hash -> Id */
 typedef Id *Hashtable;
@@ -80,7 +77,7 @@ relhash(Id name, Id evr, int flags)
  * 
  * used for Hashtable 'modulo' operation
  */ 
-static inline Hashmask
+static inline Hashval
 mkmask(unsigned int num)
 {
   num *= 2;
index 77808bd3b0d9475c619454513d1ee2d05bf3a058..bed205286c2cb40265b2ad1dffe473ed58524ad3 100644 (file)
@@ -135,7 +135,7 @@ struct _Pool {
 
   /* hash for rel unification */
   Hashtable relhashtbl;                /* hashtable: (name,evr,op)Hash -> Id */
-  Hashmask relhashmask;
+  Hashval relhashmask;
 
   Id *languagecache;
   int languagecacheother;
index 1b1987282b9d5872ef1aec7810eaf0cab2e3098a..6dc2c1b8a082ed98e426a8dbf1a02e63e631e7cc 100644 (file)
@@ -54,9 +54,7 @@ pool_strn2id(Pool *pool, const char *str, unsigned int len, int create)
 Id
 pool_rel2id(Pool *pool, Id name, Id evr, int flags, int create)
 {
-  Hashval h;
-  unsigned int hh;
-  Hashmask hashmask;
+  Hashval h, hh, hashmask;
   int i;
   Id id;
   Hashtable hashtbl;
index 130afb00fd262ebf078e6c59d287412835617db5..068482785d9bcf887f3c49c9fe6c5d51b2bd4b6a 100644 (file)
@@ -50,7 +50,7 @@ typedef struct _Repo {
   Offset lastoff;              /* start of last array in idarraydata */
 
   Hashtable lastidhash;                /* hash to speed up repo_addid_dep */
-  Hashmask lastidhash_mask;
+  Hashval lastidhash_mask;
   int lastidhash_idarraysize;
   int lastmarker;
   Offset lastmarkerpos;
index 62e399fefd76a563238198ff21c93e2f1ec16286..2835c30f6386179ea0c10bdeb069dd456406fd93 100644 (file)
@@ -453,9 +453,8 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
   char *sp;                           /* pointer into string space */
   Id *idmap;                          /* map of repo Ids to pool Ids */
   Id id, type;
-  unsigned int hashmask, h;
-  int hh;
-  Id *hashtbl;
+  Hashval hashmask, h, hh;
+  Hashtable hashtbl;
   Id name, evr, did;
   int relflags;
   Reldep *ran;
index 5a9c64a2b8fbf84ef1bcb0e459206380a374a70e..364f096f63de737604e20a7603d08e51731d2430 100644 (file)
@@ -79,9 +79,7 @@ stringpool_clone(Stringpool *ss, Stringpool *from)
 Id
 stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create)
 {
-  Hashval h;
-  unsigned int hh;
-  Hashmask hashmask, oldhashmask;
+  Hashval h, hh, hashmask, oldhashmask;
   int i;
   Id id;
   Hashtable hashtbl;
index 6745be8d3d756cd0b7fb63d7bdc5ec6185aed9b8..c97b8737d288287e1d09e20e0f99c8026bcb801a 100644 (file)
@@ -25,7 +25,7 @@ struct _Stringpool
   Offset sstrings;            /* size of used stringspace */
 
   Hashtable stringhashtbl;    /* hash table: (string ->) Hash -> Id */
-  Hashmask stringhashmask;    /* modulo value for hash table (size of table - 1) */
+  Hashval stringhashmask;     /* modulo value for hash table (size of table - 1) */
 };
 
 void stringpool_init(Stringpool *ss, const char *strs[]);