Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
683e530c
Commit
683e530c
authored
Feb 12, 2021
by
Viktor Söderqvist
Committed by
Oran Agra
Feb 16, 2021
Browse files
Use stack for decoding integer-encoded values in list push
Less heap allocations when commands like LMOVE push integer values.
parent
f521498b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_list.c
View file @
683e530c
...
@@ -41,10 +41,13 @@
...
@@ -41,10 +41,13 @@
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
)
{
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_QUICKLIST
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_QUICKLIST
)
{
int
pos
=
(
where
==
LIST_HEAD
)
?
QUICKLIST_HEAD
:
QUICKLIST_TAIL
;
int
pos
=
(
where
==
LIST_HEAD
)
?
QUICKLIST_HEAD
:
QUICKLIST_TAIL
;
value
=
getDecodedObject
(
value
);
if
(
value
->
encoding
==
OBJ_ENCODING_INT
)
{
size_t
len
=
sdslen
(
value
->
ptr
);
char
buf
[
32
];
quicklistPush
(
subject
->
ptr
,
value
->
ptr
,
len
,
pos
);
ll2string
(
buf
,
32
,
(
long
)
value
->
ptr
);
decrRefCount
(
value
);
quicklistPush
(
subject
->
ptr
,
buf
,
strlen
(
buf
),
pos
);
}
else
{
quicklistPush
(
subject
->
ptr
,
value
->
ptr
,
sdslen
(
value
->
ptr
),
pos
);
}
}
else
{
}
else
{
serverPanic
(
"Unknown list encoding"
);
serverPanic
(
"Unknown list encoding"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment