mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Avoid useless copying in LINDEX command for reply
This commit is contained in:
parent
fb3457d157
commit
f521498b43
@ -324,7 +324,6 @@ void lindexCommand(client *c) {
|
||||
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]);
|
||||
if (o == NULL || checkType(c,o,OBJ_LIST)) return;
|
||||
long index;
|
||||
robj *value = NULL;
|
||||
|
||||
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != C_OK))
|
||||
return;
|
||||
@ -333,12 +332,10 @@ void lindexCommand(client *c) {
|
||||
quicklistEntry entry;
|
||||
if (quicklistIndex(o->ptr, index, &entry)) {
|
||||
if (entry.value) {
|
||||
value = createStringObject((char*)entry.value,entry.sz);
|
||||
addReplyBulkCBuffer(c, entry.value, entry.sz);
|
||||
} else {
|
||||
value = createStringObjectFromLongLong(entry.longval);
|
||||
addReplyBulkLongLong(c, entry.longval);
|
||||
}
|
||||
addReplyBulk(c,value);
|
||||
decrRefCount(value);
|
||||
} else {
|
||||
addReplyNull(c);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user