summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-04-18 11:37:14 +0200
committerantirez <antirez@gmail.com>2012-04-18 11:37:14 +0200
commitacf41c96cbeb9fcbaefc321b65a6a7c3053be75e (patch)
tree82c97d667a007c4a161847e0f12d62446a9d81a9 /src/sort.c
parent8ec9b03c6b6bf266c2d16afc0d968181c7baea85 (diff)
downloadredis-acf41c96cbeb9fcbaefc321b65a6a7c3053be75e.tar.gz
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.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sort.c b/src/sort.c
index ff655c7e7..c1ed5517f 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -28,7 +28,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
@@ -76,7 +76,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
@@ -90,7 +90,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
incrRefCount(o);
}
decrRefCount(keyobj);
- if (fieldlen) decrRefCount(fieldobj);
+ if (fieldobj) decrRefCount(fieldobj);
return o;
noobj: