computeObjectSwappability is now able to compute swappability for intset encoded sets

This commit is contained in:
antirez 2010-08-26 12:28:53 +02:00
parent 740eee1cc6
commit 5f19e8a4a5

View File

@ -395,6 +395,10 @@ double computeObjectSwappability(robj *o) {
z = (o->type == REDIS_ZSET);
d = z ? ((zset*)o->ptr)->dict : o->ptr;
if (!z && o->encoding == REDIS_ENCODING_INTSET) {
intset *is = o->ptr;
asize = sizeof(*is)+is->encoding*is->length;
} else {
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
if (z) asize += sizeof(zset)-sizeof(dict);
if (dictSize(d)) {
@ -405,6 +409,7 @@ double computeObjectSwappability(robj *o) {
asize += (sizeof(struct dictEntry)+elesize)*dictSize(d);
if (z) asize += sizeof(zskiplistNode)*dictSize(d);
}
}
break;
case REDIS_HASH:
if (o->encoding == REDIS_ENCODING_ZIPMAP) {