diff options
author | sundb <sundbcn@gmail.com> | 2020-11-25 03:40:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 21:40:58 +0200 |
commit | 25f457c7f69e7f0254cc5d585eadd784dd30d91c (patch) | |
tree | 09a23e7b250c270b2ebbc0f1e4bbb55d191fe324 /src/t_list.c | |
parent | 7e5a6313f0add995c723351532d994118e3e8a6d (diff) | |
download | redis-25f457c7f69e7f0254cc5d585eadd784dd30d91c.tar.gz |
Avoid excessive malloc and free in copyCommand robj creation (#8067)
Avoid multiple conditional judgments
Avoid allocating robj->ptr when we're gonna replace it right after.
Diffstat (limited to 'src/t_list.c')
-rw-r--r-- | src/t_list.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/t_list.c b/src/t_list.c index ce1472d93..acabe7be2 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -202,14 +202,13 @@ robj *listTypeDup(robj *o) { switch (o->encoding) { case OBJ_ENCODING_QUICKLIST: - lobj = createQuicklistObject(); + lobj = createObject(OBJ_LIST, quicklistDup(o->ptr)); + lobj->encoding = OBJ_ENCODING_QUICKLIST; break; default: serverPanic("Wrong encoding."); break; } - zfree(lobj->ptr); - lobj->ptr = quicklistDup(o->ptr); return lobj; } |