Commit ee1ed720 authored by liuminghang's avatar liuminghang

use string in AddCommandHandler

parent 8c5de009
...@@ -436,9 +436,8 @@ std::ostream& operator<<(std::ostream& os, const RedisResponse& response) { ...@@ -436,9 +436,8 @@ std::ostream& operator<<(std::ostream& os, const RedisResponse& response) {
return os; return os;
} }
bool RedisService::AddCommandHandler(const butil::StringPiece& name, bool RedisService::AddCommandHandler(const std::string& name, RedisCommandHandler* handler) {
RedisCommandHandler* handler) { std::string lcname = StringToLowerASCII(name);
std::string lcname = StringToLowerASCII(name.as_string());
auto it = _command_map.find(lcname); auto it = _command_map.find(lcname);
if (it != _command_map.end()) { if (it != _command_map.end()) {
LOG(ERROR) << "redis command name=" << name << " exist"; LOG(ERROR) << "redis command name=" << name << " exist";
......
...@@ -222,7 +222,7 @@ public: ...@@ -222,7 +222,7 @@ public:
virtual ~RedisService() {} virtual ~RedisService() {}
// Call this function to register `handler` that can handle command `name`. // Call this function to register `handler` that can handle command `name`.
bool AddCommandHandler(const butil::StringPiece& name, RedisCommandHandler* handler); bool AddCommandHandler(const std::string& name, RedisCommandHandler* handler);
// This function should not be touched by user and used by brpc deverloper only. // This function should not be touched by user and used by brpc deverloper only.
RedisCommandHandler* FindCommandHandler(const butil::StringPiece& name) const; RedisCommandHandler* FindCommandHandler(const butil::StringPiece& name) const;
......
...@@ -420,7 +420,7 @@ ParseError RedisCommandParser::Consume(butil::IOBuf& buf, ...@@ -420,7 +420,7 @@ ParseError RedisCommandParser::Consume(butil::IOBuf& buf,
char* d = (char*)arena->allocate((len/8 + 1) * 8); char* d = (char*)arena->allocate((len/8 + 1) * 8);
buf.cutn(d, len); buf.cutn(d, len);
d[len] = '\0'; d[len] = '\0';
_args[_index] = butil::StringPiece(d, len); _args[_index].set(d, len);
if (_index == 0) { if (_index == 0) {
// convert it to lowercase when it is command name // convert it to lowercase when it is command name
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment