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
e9484a85
Commit
e9484a85
authored
Apr 01, 2010
by
Pieter Noordhuis
Browse files
reduce code complexity because zipmapLen now is O(1)
parent
da2cfe8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
e9484a85
...
@@ -5937,10 +5937,8 @@ static void hsetCommand(redisClient *c) {
...
@@ -5937,10 +5937,8 @@ static void hsetCommand(redisClient *c) {
decrRefCount(valobj);
decrRefCount(valobj);
o->ptr = zm;
o->ptr = zm;
/* And here there is the second check for hash conversion...
/* And here there is the second check for hash conversion. */
* we want to do it only if the operation was not just an update as
if (zipmapLen(zm) > server.hash_max_zipmap_entries)
* zipmapLen() is O(N). */
if (!update && zipmapLen(zm) > server.hash_max_zipmap_entries)
convertToRealHash(o);
convertToRealHash(o);
} else {
} else {
tryObjectEncoding(c->argv[2]);
tryObjectEncoding(c->argv[2]);
...
@@ -5958,7 +5956,6 @@ static void hsetCommand(redisClient *c) {
...
@@ -5958,7 +5956,6 @@ static void hsetCommand(redisClient *c) {
}
}
static void hincrbyCommand(redisClient *c) {
static void hincrbyCommand(redisClient *c) {
int update = 0;
long long value = 0, incr = 0;
long long value = 0, incr = 0;
robj *o = lookupKeyWrite(c->db,c->argv[1]);
robj *o = lookupKeyWrite(c->db,c->argv[1]);
...
@@ -5995,13 +5992,12 @@ static void hincrbyCommand(redisClient *c) {
...
@@ -5995,13 +5992,12 @@ static void hincrbyCommand(redisClient *c) {
value += incr;
value += incr;
sds svalue = sdscatprintf(sdsempty(),"%lld",value);
sds svalue = sdscatprintf(sdsempty(),"%lld",value);
zm = zipmapSet(zm,c->argv[2]->ptr,sdslen(c->argv[2]->ptr),
zm = zipmapSet(zm,c->argv[2]->ptr,sdslen(c->argv[2]->ptr),
(unsigned char*)svalue,sdslen(svalue),
&update
);
(unsigned char*)svalue,sdslen(svalue),
NULL
);
sdsfree(svalue);
sdsfree(svalue);
o->ptr = zm;
o->ptr = zm;
/* Check if the zipmap needs to be converted
/* Check if the zipmap needs to be converted. */
* if this was not an update. */
if (zipmapLen(zm) > server.hash_max_zipmap_entries)
if (!update && zipmapLen(zm) > server.hash_max_zipmap_entries)
convertToRealHash(o);
convertToRealHash(o);
} else {
} else {
robj *hval;
robj *hval;
...
...
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