Rework comment in dictEncObjKeyCompare().

This commit is contained in:
antirez 2020-04-27 22:40:15 +02:00
parent 94dcdaeaf0
commit bee51ef883

View File

@ -1219,16 +1219,15 @@ int dictEncObjKeyCompare(void *privdata, const void *key1,
o2->encoding == OBJ_ENCODING_INT) o2->encoding == OBJ_ENCODING_INT)
return o1->ptr == o2->ptr; return o1->ptr == o2->ptr;
/* due to OBJ_STATIC_REFCOUNT, we rather not call sdsEncodedObject unnecessarily */ /* Due to OBJ_STATIC_REFCOUNT, we avoid calling getDecodedObject() without
if (!sdsEncodedObject(o1)) * good reasons, because it would incrRefCount() the object, which
o1 = getDecodedObject(o1); * is invalid. So we check to make sure dictFind() works with static
if (!sdsEncodedObject(o2)) * objects as well. */
o2 = getDecodedObject(o2); if (!sdsEncodedObject(o1)) o1 = getDecodedObject(o1);
if (!sdsEncodedObject(o2)) o2 = getDecodedObject(o2);
cmp = dictSdsKeyCompare(privdata,o1->ptr,o2->ptr); cmp = dictSdsKeyCompare(privdata,o1->ptr,o2->ptr);
if (o1!=key1) if (o1!=key1) decrRefCount(o1);
decrRefCount(o1); if (o2!=key2) decrRefCount(o2);
if (o2!=key2)
decrRefCount(o2);
return cmp; return cmp;
} }