Skip to content

Commit

Permalink
Avoid useless copying in LINDEX command for reply
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiderkwast authored and oranagra committed Feb 16, 2021
1 parent fb3457d commit f521498
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/t_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit f521498

Please sign in to comment.