diff options
author | Viktor Söderqvist <viktor.soderqvist@est.tech> | 2021-02-12 12:31:41 +0100 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2021-02-16 13:01:14 +0200 |
commit | 683e530cf3c3e71266b8d18073fd026da9de4ddb (patch) | |
tree | 7b82a25c84f885ebf27dc211742f0aacda1428ee /src/t_list.c | |
parent | f521498b43a8edcec01c88dc7361eaac460f2f6c (diff) | |
download | redis-683e530cf3c3e71266b8d18073fd026da9de4ddb.tar.gz |
Use stack for decoding integer-encoded values in list push
Less heap allocations when commands like LMOVE push integer values.
Diffstat (limited to 'src/t_list.c')
-rw-r--r-- | src/t_list.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/t_list.c b/src/t_list.c index 7b7cbe01f..961f59ae4 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -41,10 +41,13 @@ void listTypePush(robj *subject, robj *value, int where) { if (subject->encoding == OBJ_ENCODING_QUICKLIST) { int pos = (where == LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL; - value = getDecodedObject(value); - size_t len = sdslen(value->ptr); - quicklistPush(subject->ptr, value->ptr, len, pos); - decrRefCount(value); + if (value->encoding == OBJ_ENCODING_INT) { + char buf[32]; + ll2string(buf, 32, (long)value->ptr); + quicklistPush(subject->ptr, buf, strlen(buf), pos); + } else { + quicklistPush(subject->ptr, value->ptr, sdslen(value->ptr), pos); + } } else { serverPanic("Unknown list encoding"); } |