From 5f8ee3815c09595e8b6cd166fe8a3da18ff1d0fd Mon Sep 17 00:00:00 2001 From: Axlgrep Date: Tue, 16 Nov 2021 23:03:24 +0800 Subject: [PATCH] optimze the judgment logic of use_pattern in scanGenericCommand() (#9789) in `scan 0 match ""` case, pat is empty sds(patlen is 0), I don't think should access the first character directly in this case(even though the first character is ' \0 '), for the code readability, I switch the two positions of judgment logic. --- src/db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index 5d44a9ab9..8f1b376a0 100644 --- a/src/db.c +++ b/src/db.c @@ -832,7 +832,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { /* The pattern always matches if it is exactly "*", so it is * equivalent to disabling it. */ - use_pattern = !(pat[0] == '*' && patlen == 1); + use_pattern = !(patlen == 1 && pat[0] == '*'); i += 2; } else if (!strcasecmp(c->argv[i]->ptr, "type") && o == NULL && j >= 2) {