jamesge commented on a change in pull request #1128:
URL: https://github.com/apache/incubator-brpc/pull/1128#discussion_r436568422



##########
File path: src/brpc/redis_command.cpp
##########
@@ -420,7 +420,7 @@ ParseError RedisCommandParser::Consume(butil::IOBuf& buf,
     char* d = (char*)arena->allocate((len/8 + 1) * 8);
     buf.cutn(d, len);
     d[len] = '\0';
-    _commands[_index] = d;
+    _args[_index] = butil::StringPiece(d, len);

Review comment:
       _args[_index].set(d, len);

##########
File path: src/brpc/redis.cpp
##########
@@ -436,8 +436,9 @@ std::ostream& operator<<(std::ostream& os, const 
RedisResponse& response) {
     return os;
 }
 
-bool RedisService::AddCommandHandler(const std::string& name, 
RedisCommandHandler* handler) {
-    std::string lcname = StringToLowerASCII(name);
+bool RedisService::AddCommandHandler(const butil::StringPiece& name, 
+                                     RedisCommandHandler* handler) {
+    std::string lcname = StringToLowerASCII(name.as_string());

Review comment:
       不用as_string,本就支持StringPiece。如果还得转成string,参数用StringPiece就没有意义了

##########
File path: src/brpc/redis.cpp
##########
@@ -447,9 +448,8 @@ bool RedisService::AddCommandHandler(const std::string& 
name, RedisCommandHandle
     return true;
 }
  
-RedisCommandHandler* RedisService::FindCommandHandler(const std::string& name) 
const {
-    std::string lcname = StringToLowerASCII(name);
-    auto it = _command_map.find(lcname);
+RedisCommandHandler* RedisService::FindCommandHandler(const 
butil::StringPiece& name) const {
+    auto it = _command_map.find(name.as_string());

Review comment:
       和老代码不一致。




----------------------------------------------------------------
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]



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

Reply via email to