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) { ...@@ -324,7 +324,6 @@ void lindexCommand(client *c) {
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]); robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]);
if (o == NULL || checkType(c,o,OBJ_LIST)) return; if (o == NULL || checkType(c,o,OBJ_LIST)) return;
long index; long index;
robj *value = NULL;
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != C_OK)) if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != C_OK))
return; return;
...@@ -333,12 +332,10 @@ void lindexCommand(client *c) { ...@@ -333,12 +332,10 @@ void lindexCommand(client *c) {
quicklistEntry entry; quicklistEntry entry;
if (quicklistIndex(o->ptr, index, &entry)) { if (quicklistIndex(o->ptr, index, &entry)) {
if (entry.value) { if (entry.value) {
value = createStringObject((char*)entry.value,entry.sz); addReplyBulkCBuffer(c, entry.value, entry.sz);
} else { } else {
value = createStringObjectFromLongLong(entry.longval); addReplyBulkLongLong(c, entry.longval);
} }
addReplyBulk(c,value);
decrRefCount(value);
} else { } else {
addReplyNull(c); 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