From c4ca5f99bf4ce0c2424b870128c3f398f8675b36 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 31 Oct 2013 10:35:56 +0100 Subject: [PATCH] Inverted variable boolean value and name after scanGenericCommand() refactoring. --- src/db.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/db.c b/src/db.c index 234f80f5..d490e2aa 100644 --- a/src/db.c +++ b/src/db.c @@ -370,7 +370,7 @@ void scanGenericCommand(redisClient *c, robj *o) { unsigned long cursor = 0; long count = 10; sds pat; - int patlen, patnoop = 1; + int patlen, use_pattern = 0; dict *ht; /* Object must be NULL (to iterate keys names), or the type of the object @@ -408,8 +408,9 @@ void scanGenericCommand(redisClient *c, robj *o) { pat = c->argv[i+1]->ptr; patlen = sdslen(pat); - /* The pattern is a no-op iff == "*" */ - patnoop = (pat[0] == '*' && patlen == 1); + /* The pattern always matches if it is exactly "*", so it is + * equivalent to disabling it. */ + use_pattern = !(pat[0] == '*' && patlen == 1); i += 2; } else { @@ -483,7 +484,7 @@ void scanGenericCommand(redisClient *c, robj *o) { int filter = 0; /* Filter element if it does not match the pattern. */ - if (!filter && !patnoop) { + if (!filter && use_pattern) { if (sdsEncodedObject(kobj)) { if (!stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0)) filter = 1; -- GitLab