summaryrefslogtreecommitdiff
path: root/src/t_list.c
diff options
context:
space:
mode:
authorViktor Söderqvist <viktor.soderqvist@est.tech>2021-02-12 12:20:54 +0100
committerOran Agra <oran@redislabs.com>2021-02-16 13:01:14 +0200
commitf521498b43a8edcec01c88dc7361eaac460f2f6c (patch)
treef58ae877abab13509ea99aa16de9a8cb4a2b2386 /src/t_list.c
parentfb3457d157a1b79665891d2a2bfc997e47978a94 (diff)
downloadredis-f521498b43a8edcec01c88dc7361eaac460f2f6c.tar.gz
Avoid useless copying in LINDEX command for reply
Diffstat (limited to 'src/t_list.c')
-rw-r--r--src/t_list.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/t_list.c b/src/t_list.c
index f019a7ec0..7b7cbe01f 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -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);
}