summaryrefslogtreecommitdiff
path: root/lib/fprint.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-03-10 09:00:07 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-03-10 10:17:39 +0200
commit805f7fd5af6fb4527f8487049565437a4ab11ecd (patch)
treef25b9229501024b9497cd322b29d7ef5a4791a4c /lib/fprint.c
parentba38b2551f51538885df60b849906de005fb78ed (diff)
downloadlibrpm-tizen-805f7fd5af6fb4527f8487049565437a4ab11ecd.tar.gz
librpm-tizen-805f7fd5af6fb4527f8487049565437a4ab11ecd.tar.bz2
librpm-tizen-805f7fd5af6fb4527f8487049565437a4ab11ecd.zip
Move string hash function to librpmio and rename for namespacing
- There are places in rpmio and build that would benefit from hashing, but hashFunctionString() being internal to librpm has prevented that. Rename to rstrhash() to resemble the other foo in rpmstring.h for minimal namespacing as its now public function and update callers. - Also mark the function as "pure" - it only looks at its arguments. This is one of the busiest functions in entire rpm so any optimization no matter how minor is well worth it. - Hereby awarding hashFunctionString() with the grand prize for the Most Moved Around Function in rpm ;)
Diffstat (limited to 'lib/fprint.c')
-rw-r--r--lib/fprint.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index 228922450..c894513ec 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -29,7 +29,7 @@ fingerPrintCache fpCacheCreate(int sizeHint)
fingerPrintCache fpc;
fpc = xmalloc(sizeof(*fpc));
- fpc->ht = rpmFpEntryHashCreate(sizeHint, hashFunctionString, strcmp,
+ fpc->ht = rpmFpEntryHashCreate(sizeHint, rstrhash, strcmp,
(rpmFpEntryHashFreeKey)free,
(rpmFpEntryHashFreeData)free);
return fpc;
@@ -195,8 +195,8 @@ unsigned int fpHashFunction(const fingerPrint * fp)
unsigned int hash = 0;
int j;
- hash = hashFunctionString(fp->baseName);
- if (fp->subDir) hash ^= hashFunctionString(fp->subDir);
+ hash = rstrhash(fp->baseName);
+ if (fp->subDir) hash ^= rstrhash(fp->subDir);
hash ^= ((unsigned)fp->entry->dev);
for (j=0; j<4; j++) hash ^= ((fp->entry->ino >> (8*j)) & 0xFF) << ((3-j)*8);