From afd438dfff7112bec97b62640b6a2c4ec73fcf4e Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 10 Dec 2010 19:15:00 +0100 Subject: [PATCH] previouse INCR implementation restored, was actually faster for some reson not fully clear at the moment --- src/t_string.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/t_string.c b/src/t_string.c index bb6b4ece..39ee506d 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -144,24 +144,8 @@ void incrDecrCommand(redisClient *c, long long incr) { o = lookupKeyWrite(c->db,c->argv[1]); if (o != NULL && checkType(c,o,REDIS_STRING)) return; - - /* Fast path if the object is integer encoded and is not shared. */ - if (o && o->refcount == 1 && o->encoding == REDIS_ENCODING_INT) { - long long newval = ((long)o->ptr) + incr; - - if (newval < 0 && newval >= REDIS_SHARED_INTEGERS && - newval >= LONG_MIN && newval <= LONG_MAX) { - o->ptr = (void*) (long) newval; - touchWatchedKey(c->db,c->argv[1]); - server.dirty++; - addReplyLongLong(c,newval); - return; - } - /* ... else take the usual safe path */ - } - - /* Otherwise we create a new object and replace the old one. */ if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return; + value += incr; o = createStringObjectFromLongLong(value); dbReplace(c->db,c->argv[1],o); -- 2.45.2