mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
Avoid the sdslen() on shared.crlf given we know its size beforehand. Improve ~3-4% of cpu cycles to lrange logic (#10987)
* Avoid the sdslen() on shared.crlf given we know its size beforehand * Removed shared.crlf from sharedObjects
This commit is contained in:
@@ -860,7 +860,7 @@ void addReplyBigNum(client *c, const char* num, size_t len) {
|
||||
} else {
|
||||
addReplyProto(c,"(",1);
|
||||
addReplyProto(c,num,len);
|
||||
addReply(c,shared.crlf);
|
||||
addReplyProto(c,"\r\n",2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -991,21 +991,21 @@ void addReplyBulkLen(client *c, robj *obj) {
|
||||
void addReplyBulk(client *c, robj *obj) {
|
||||
addReplyBulkLen(c,obj);
|
||||
addReply(c,obj);
|
||||
addReply(c,shared.crlf);
|
||||
addReplyProto(c,"\r\n",2);
|
||||
}
|
||||
|
||||
/* Add a C buffer as bulk reply */
|
||||
void addReplyBulkCBuffer(client *c, const void *p, size_t len) {
|
||||
addReplyLongLongWithPrefix(c,len,'$');
|
||||
addReplyProto(c,p,len);
|
||||
addReply(c,shared.crlf);
|
||||
addReplyProto(c,"\r\n",2);
|
||||
}
|
||||
|
||||
/* Add sds to reply (takes ownership of sds and frees it) */
|
||||
void addReplyBulkSds(client *c, sds s) {
|
||||
addReplyLongLongWithPrefix(c,sdslen(s),'$');
|
||||
addReplySds(c,s);
|
||||
addReply(c,shared.crlf);
|
||||
addReplyProto(c,"\r\n",2);
|
||||
}
|
||||
|
||||
/* Set sds to a deferred reply (for symmetry with addReplyBulkSds it also frees the sds) */
|
||||
|
||||
@@ -1680,7 +1680,6 @@ void createSharedObjects(void) {
|
||||
int j;
|
||||
|
||||
/* Shared command responses */
|
||||
shared.crlf = createObject(OBJ_STRING,sdsnew("\r\n"));
|
||||
shared.ok = createObject(OBJ_STRING,sdsnew("+OK\r\n"));
|
||||
shared.emptybulk = createObject(OBJ_STRING,sdsnew("$0\r\n\r\n"));
|
||||
shared.czero = createObject(OBJ_STRING,sdsnew(":0\r\n"));
|
||||
|
||||
@@ -1222,7 +1222,7 @@ struct sentinelConfig {
|
||||
};
|
||||
|
||||
struct sharedObjectsStruct {
|
||||
robj *crlf, *ok, *err, *emptybulk, *czero, *cone, *pong, *space,
|
||||
robj *ok, *err, *emptybulk, *czero, *cone, *pong, *space,
|
||||
*queued, *null[4], *nullarray[4], *emptymap[4], *emptyset[4],
|
||||
*emptyarray, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr,
|
||||
*outofrangeerr, *noscripterr, *loadingerr,
|
||||
|
||||
Reference in New Issue
Block a user