MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / dictEncObjKeyCompare

Function dictEncObjKeyCompare

src/server.cpp:1410–1430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1408}
1409
1410int dictEncObjKeyCompare(void *privdata, const void *key1,
1411 const void *key2)
1412{
1413 robj *o1 = (robj*) key1, *o2 = (robj*) key2;
1414 int cmp;
1415
1416 if (o1->encoding == OBJ_ENCODING_INT &&
1417 o2->encoding == OBJ_ENCODING_INT)
1418 return ptrFromObj(o1) == ptrFromObj(o2);
1419
1420 /* Due to OBJ_STATIC_REFCOUNT, we avoid calling getDecodedObject() without
1421 * good reasons, because it would incrRefCount() the object, which
1422 * is invalid. So we check to make sure dictFind() works with static
1423 * objects as well. */
1424 if (o1->getrefcount() != OBJ_STATIC_REFCOUNT) o1 = getDecodedObject(o1);
1425 if (o2->getrefcount() != OBJ_STATIC_REFCOUNT) o2 = getDecodedObject(o2);
1426 cmp = dictSdsKeyCompare(privdata,ptrFromObj(o1),ptrFromObj(o2));
1427 if (o1->getrefcount() != OBJ_STATIC_REFCOUNT) decrRefCount(o1);
1428 if (o2->getrefcount() != OBJ_STATIC_REFCOUNT) decrRefCount(o2);
1429 return cmp;
1430}
1431
1432uint64_t dictEncObjHash(const void *key) {
1433 robj *o = (robj*) key;

Callers

nothing calls this directly

Calls 5

ptrFromObjFunction · 0.85
getDecodedObjectFunction · 0.85
decrRefCountFunction · 0.85
getrefcountMethod · 0.80
dictSdsKeyCompareFunction · 0.70

Tested by

no test coverage detected