From c9820ec97b417d33dc37eb589f069766f1068ea1 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 29 Jan 2011 11:47:31 +1000 Subject: Slightly more efficient rehash size selection While probably still not optimal in terms of everyday usage in pacman, this reduces the absolute size increase to "more reasonable" levels. For databases greater than 5000 in size, the minimum size increase is used which is still on the order of a 10% increase. Signed-off-by: Allan McRae --- lib/libalpm/pkghash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/pkghash.c') diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c index 0324465f..8f7168d2 100644 --- a/lib/libalpm/pkghash.c +++ b/lib/libalpm/pkghash.c @@ -98,10 +98,12 @@ static pmpkghash_t *rehash(pmpkghash_t *oldhash) * require a table size increase that large. */ if(oldhash->buckets < 500) { newsize = oldhash->buckets * 2; - } else if(oldhash->buckets < 3500) { + } else if(oldhash->buckets < 2000) { newsize = oldhash->buckets * 3 / 2; - } else { + } else if(oldhash->buckets < 5000) { newsize = oldhash->buckets * 4 / 3; + } else { + newsize = oldhash->buckets + 1; } newhash = _alpm_pkghash_create(newsize); -- cgit v1.2.3-24-g4f1b