From f491eee2a1ef44b0b62380ee07f873e0c22be5e0 Mon Sep 17 00:00:00 2001 From: Huang Zhw Date: Mon, 8 Mar 2021 00:09:12 +0800 Subject: [PATCH] Cleanup: dictEncObjHash remove redundant conditional statement (#8488) --- src/server.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/server.c b/src/server.c index 20ada1404..26fe57499 100644 --- a/src/server.c +++ b/src/server.c @@ -1332,21 +1332,14 @@ uint64_t dictEncObjHash(const void *key) { if (sdsEncodedObject(o)) { return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr)); + } else if (o->encoding == OBJ_ENCODING_INT) { + char buf[32]; + int len; + + len = ll2string(buf,32,(long)o->ptr); + return dictGenHashFunction((unsigned char*)buf, len); } else { - if (o->encoding == OBJ_ENCODING_INT) { - char buf[32]; - int len; - - len = ll2string(buf,32,(long)o->ptr); - return dictGenHashFunction((unsigned char*)buf, len); - } else { - uint64_t hash; - - o = getDecodedObject(o); - hash = dictGenHashFunction(o->ptr, sdslen((sds)o->ptr)); - decrRefCount(o); - return hash; - } + serverPanic("Unknown string encoding"); } }