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
2e12082b
Commit
2e12082b
authored
Mar 10, 2011
by
Pieter Noordhuis
Browse files
Make zzlLength take a ziplist argument
parent
08532b1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
2e12082b
...
...
@@ -449,9 +449,7 @@ int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int cl
return
cmp
;
}
unsigned
int
zzlLength
(
robj
*
zobj
)
{
unsigned
char
*
zl
=
zobj
->
ptr
;
redisAssert
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
);
unsigned
int
zzlLength
(
unsigned
char
*
zl
)
{
return
ziplistLen
(
zl
)
/
2
;
}
...
...
@@ -720,7 +718,7 @@ unsigned long zzlDeleteRangeByRank(robj *zobj, unsigned int start, unsigned int
int
zsLength
(
robj
*
zobj
)
{
int
length
=
-
1
;
if
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
length
=
zzlLength
(
zobj
);
length
=
zzlLength
(
zobj
->
ptr
);
}
else
if
(
zobj
->
encoding
==
REDIS_ENCODING_RAW
)
{
length
=
((
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
}
else
{
...
...
@@ -874,7 +872,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
/* Optimize: check if the element is too large or the list becomes
* too long *before* executing zzlInsert. */
redisAssert
(
zzlInsert
(
zobj
,
ele
,
score
)
==
REDIS_OK
);
if
(
zzlLength
(
zobj
)
>
server
.
zset_max_ziplist_entries
)
if
(
zzlLength
(
zobj
->
ptr
)
>
server
.
zset_max_ziplist_entries
)
zsConvert
(
zobj
,
REDIS_ENCODING_RAW
);
if
(
sdslen
(
ele
->
ptr
)
>
server
.
zset_max_ziplist_value
)
zsConvert
(
zobj
,
REDIS_ENCODING_RAW
);
...
...
@@ -965,7 +963,7 @@ void zremCommand(redisClient *c) {
if
((
eptr
=
zzlFind
(
zobj
,
ele
,
NULL
))
!=
NULL
)
{
redisAssert
(
zzlDelete
(
zobj
,
eptr
)
==
REDIS_OK
);
if
(
zzlLength
(
zobj
)
==
0
)
dbDelete
(
c
->
db
,
key
);
if
(
zzlLength
(
zobj
->
ptr
)
==
0
)
dbDelete
(
c
->
db
,
key
);
}
else
{
addReply
(
c
,
shared
.
czero
);
return
;
...
...
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