Unverified Commit f2d59c4f authored by Chen Tianjie's avatar Chen Tianjie Committed by GitHub
Browse files

Avoid unnecessary slot computing in KEYS command. (#12843)

If not in cluster mode, there is no need to compute slot.

A bit optimization for #12754
parent 8e11f84d
......@@ -1003,12 +1003,12 @@ void keysCommand(client *c) {
long numkeys = 0;
void *replylen = addReplyDeferredLen(c);
allkeys = (pattern[0] == '*' && plen == 1);
if (!allkeys) {
if (server.cluster_enabled && !allkeys) {
pslot = patternHashSlot(pattern, plen);
}
dictIterator *di = NULL;
dbIterator *dbit = NULL;
if (server.cluster_enabled && !allkeys && pslot != -1) {
if (pslot != -1) {
di = dictGetSafeIterator(c->db->dict[pslot]);
} else {
dbit = dbIteratorInit(c->db, DB_MAIN);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment