4.0.4-alt98.11

- rpmdb: Minor fingerprint cache improvement.
This commit is contained in:
Alexey Tourbin 2009-06-13 09:14:24 +04:00
commit 5b60d490d6
3 changed files with 24 additions and 33 deletions

View File

@ -4,7 +4,7 @@
Name: %rpm_name
Version: %rpm_version
Release: alt98.10
Release: alt98.11
%define ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
%define get_dep() %(rpm -q --qf '%%{NAME} >= %%|SERIAL?{%%{SERIAL}:}|%%{VERSION}-%%{RELEASE}' %1 2>/dev/null || echo '%1 >= unknown')
@ -518,6 +518,9 @@ fi
%endif #with contrib
%changelog
* Sat Jun 13 2009 Alexey Tourbin <at@altlinux.ru> 4.0.4-alt98.11
- rpmdb: Minor fingerprint cache improvement.
* Wed May 20 2009 Dmitry V. Levin <ldv@altlinux.org> 4.0.4-alt98.10
- brp-compress: Avoid non-standard info directories (closes: #19993).
- rpm-build: Implemented info files verification.

View File

@ -10,21 +10,24 @@
#include "fprint.h"
#include "debug.h"
#include "rpmhash.h"
#include "jhash.h"
struct fprintCache_s {
hashTable dn2de; /*!< maps dirName to fprintCacheEntry */
};
fingerPrintCache fpCacheCreate(unsigned int size)
{
fingerPrintCache fpc;
fpc = xmalloc(sizeof(*fpc));
fpc->ht = htCreate(size, hashFunctionString, hashEqualityString);
fingerPrintCache fpc = xmalloc(sizeof(*fpc));
fpc->dn2de = htCreate(size, hashFunctionString, hashEqualityString);
return fpc;
}
fingerPrintCache fpCacheFree(fingerPrintCache cache)
{
/* don't free keys: key=dirname is part of value=entry, see below */
cache->ht = htFree(cache->ht, NULL, _free);
/* don't free keys: key=dirname is flexible member of value=entry */
cache->dn2de = htFree(cache->dn2de, NULL, _free);
cache = _free(cache);
return NULL;
}
@ -42,7 +45,7 @@ static /*@null@*/ const struct fprintCacheEntry_s * cacheContainsDirectory(
{
const void ** data;
if (htGetEntry(cache->ht, dirName, &data, NULL, NULL))
if (htGetEntry(cache->dn2de, dirName, &data, NULL, NULL))
return NULL;
return data[0];
}
@ -131,22 +134,16 @@ static fingerPrint doLookup(fingerPrintCache cache,
if (cacheHit != NULL) {
fp.entry = cacheHit;
} else if (!stat((*buf != '\0' ? buf : "/"), &sb)) {
/* single malloc for both key=dirname and value=entry */
size_t nb = sizeof(*fp.entry) + (*buf != '\0' ? (end-buf) : 1) + 1;
struct fprintCacheEntry_s *newEntry = xmalloc(nb);
/* dirName has a byte for terminating '\0' */
size_t nb = sizeof(*fp.entry) + (*buf != '\0' ? (end-buf) : 1);
struct fprintCacheEntry_s *de = xmalloc(nb);
/*@-usereleased@*/ /* LCL: contiguous malloc confusion */
char *dn = (char *)(newEntry + 1);
strcpy(dn, (*buf != '\0' ? buf : "/"));
newEntry->ino = sb.st_ino;
newEntry->dev = sb.st_dev;
newEntry->dirName = dn;
fp.entry = newEntry;
de->ino = sb.st_ino;
de->dev = sb.st_dev;
strcpy(de->dirName, (*buf != '\0' ? buf : "/"));
/*@-kepttrans -dependenttrans @*/
htAddEntry(cache->ht, dn, fp.entry);
/*@=kepttrans =dependenttrans @*/
/*@=usereleased@*/
htAddEntry(cache->dn2de, de->dirName, de);
fp.entry = de;
}
if (fp.entry) {

View File

@ -6,10 +6,8 @@
* Identify a file name path by a unique "finger print".
*/
#include "rpmhash.h"
#include "header.h"
/**
* Finger print cache.
*/
typedef /*@abstract@*/ struct fprintCache_s * fingerPrintCache;
@ -25,16 +23,9 @@ typedef struct fingerPrint_s fingerPrint;
* installs of a system w/o actually mounting filesystems.
*/
struct fprintCacheEntry_s {
const char * dirName; /*!< path to existing directory */
dev_t dev; /*!< stat(2) device number */
ino_t ino; /*!< stat(2) inode number */
};
/**
* Finger print cache.
*/
struct fprintCache_s {
hashTable ht; /*!< hashed by dirName */
char dirName[1]; /*!< path to existing directory */
};
/**