jamesge commented on a change in pull request #972: Redis server protocol
URL: https://github.com/apache/incubator-brpc/pull/972#discussion_r360761754
 
 

 ##########
 File path: src/brpc/redis_command.cpp
 ##########
 @@ -18,45 +18,30 @@
 // Authors: Ge,Jun ([email protected])
 
 #include "butil/logging.h"
+#include "butil/string_printf.h"
 #include "brpc/log.h"
 #include "brpc/redis_command.h"
 
-// Defined in src/butil/iobuf.cpp
-void* fast_memcpy(void *__restrict dest, const void *__restrict src, size_t n);
-
 namespace brpc {
 
 const size_t CTX_WIDTH = 5;
 
-// Much faster than snprintf(..., "%lu", d);
-inline size_t AppendDecimal(char* outbuf, unsigned long d) {
-    char buf[24];  // enough for decimal 64-bit integers
-    size_t n = sizeof(buf);
-    do {
-        const unsigned long q = d / 10;
-        buf[--n] = d - q * 10 + '0';
-        d = q;
-    } while (d);
-    fast_memcpy(outbuf, buf + n, sizeof(buf) - n);
-    return sizeof(buf) - n;
-}
-
 // This function is the hotspot of RedisCommandFormatV() when format is
 // short or does not have many %. In a 100K-time call to formating of
 // "GET key1", the time spent on RedisRequest.AddCommand() are ~700ns
 // vs. ~400ns while using snprintf() vs. AppendDecimal() respectively.
 inline void AppendHeader(std::string& buf, char fc, unsigned long value) {
     char header[32];
     header[0] = fc;
-    size_t len = AppendDecimal(header + 1, value);
+    size_t len = butil::AppendDecimal(header + 1, value);
 
 Review comment:
   这里是unsigned long,你改成了long版本,这里直接传并不ok。比如value取(unsigned long)-1这种值时

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to