Commit f521498b authored by Viktor Söderqvist's avatar Viktor Söderqvist Committed by Oran Agra
Browse files

Avoid useless copying in LINDEX command for reply

parent fb3457d1
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment