mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
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.
This commit is contained in:
parent
8ec9b03c6b
commit
acf41c96cb
@ -28,7 +28,7 @@ redisSortOperation *createSortOperation(int type, robj *pattern) {
|
|||||||
robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
|
robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
|
||||||
char *p, *f, *k;
|
char *p, *f, *k;
|
||||||
sds spat, ssub;
|
sds spat, ssub;
|
||||||
robj *keyobj, *fieldobj, *o;
|
robj *keyobj, *fieldobj = NULL, *o;
|
||||||
int prefixlen, sublen, postfixlen, fieldlen;
|
int prefixlen, sublen, postfixlen, fieldlen;
|
||||||
|
|
||||||
/* If the pattern is "#" return the substitution object itself in order
|
/* 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);
|
o = lookupKeyRead(db,keyobj);
|
||||||
if (o == NULL) goto noobj;
|
if (o == NULL) goto noobj;
|
||||||
|
|
||||||
if (fieldlen > 0) {
|
if (fieldobj) {
|
||||||
if (o->type != REDIS_HASH) goto noobj;
|
if (o->type != REDIS_HASH) goto noobj;
|
||||||
|
|
||||||
/* Retrieve value from hash by the field name. This operation
|
/* Retrieve value from hash by the field name. This operation
|
||||||
@ -90,7 +90,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
|
|||||||
incrRefCount(o);
|
incrRefCount(o);
|
||||||
}
|
}
|
||||||
decrRefCount(keyobj);
|
decrRefCount(keyobj);
|
||||||
if (fieldlen) decrRefCount(fieldobj);
|
if (fieldobj) decrRefCount(fieldobj);
|
||||||
return o;
|
return o;
|
||||||
|
|
||||||
noobj:
|
noobj:
|
||||||
|
Loading…
Reference in New Issue
Block a user