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
73582497
Commit
73582497
authored
Dec 10, 2014
by
Matt Stancliff
Browse files
Convert RDB ziplist loading to sdsnative()
This saves us an unnecessary zmalloc, memcpy, and two frees.
parent
23a93d5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/rdb.c
View file @
73582497
...
...
@@ -981,13 +981,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
rdbtype
==
REDIS_RDB_TYPE_ZSET_ZIPLIST
||
rdbtype
==
REDIS_RDB_TYPE_HASH_ZIPLIST
)
{
robj
*
aux
=
rdbLoadStringObject
(
rdb
);
if
(
aux
==
NULL
)
return
NULL
;
o
=
createObject
(
REDIS_STRING
,
NULL
);
/* string is just placeholder */
o
->
ptr
=
zmalloc
(
sdslen
(
aux
->
ptr
));
memcpy
(
o
->
ptr
,
aux
->
ptr
,
sdslen
(
aux
->
ptr
));
decrRefCount
(
aux
);
o
=
rdbLoadStringObject
(
rdb
);
if
(
o
==
NULL
)
return
NULL
;
o
->
ptr
=
sdsnative
(
o
->
ptr
);
/* Fix the object encoding, and make sure to convert the encoded
* data type into the base type if accordingly to the current
...
...
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