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.
This commit is contained in:
Axlgrep 2021-11-16 23:03:24 +08:00 committed by GitHub
parent 992a610fe8
commit 5f8ee3815c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {