Permalink
Browse files

Marginally cleaner lookupKeyByPattern() implementation.

just fieldobj itself as sentinel of the fact a field object is used or
not, instead of using the filed length, that may be confusing both for
people and for the compiler emitting a warning.
  • Loading branch information...
antirez committed Apr 18, 2012
1 parent 8e5e8f0 commit 32fef1566ac4ae67067132ae8ef7d92acf360c61
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/sort.c
View
@@ -27,7 +27,7 @@ redisSortOperation *createSortOperation(int type, robj *pattern) {
robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
char *p, *f, *k;
sds spat, ssub;
- robj *keyobj, *fieldobj, *o;
+ robj *keyobj, *fieldobj = NULL, *o;
int prefixlen, sublen, postfixlen, fieldlen;
/* If the pattern is "#" return the substitution object itself in order
@@ -75,7 +75,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
o = lookupKeyRead(db,keyobj);
if (o == NULL) goto noobj;
- if (fieldlen > 0) {
+ if (fieldobj) {
if (o->type != REDIS_HASH) goto noobj;
/* Retrieve value from hash by the field name. This operation
@@ -89,7 +89,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
incrRefCount(o);
}
decrRefCount(keyobj);
- if (fieldlen) decrRefCount(fieldobj);
+ if (fieldobj) decrRefCount(fieldobj);
return o;
noobj:

0 comments on commit 32fef15

Please sign in to comment.