RiversJin commented on code in PR #2627:
URL: https://github.com/apache/kvrocks/pull/2627#discussion_r1820413709
##########
src/server/redis_reply.cc:
##########
@@ -37,9 +37,23 @@ namespace redis {
void Reply(evbuffer *output, const std::string &data) { evbuffer_add(output,
data.c_str(), data.length()); }
-std::string SimpleString(const std::string &data) { return "+" + data + CRLF; }
+std::string SimpleString(std::string_view data) {
+ std::string res;
+ res.reserve(data.size() + 3); // 1 for '+', 2 for CRLF
+ res += RESP_PREFIX_SIMPLE_STRING;
+ res += data;
+ res += CRLF;
+ return res;
+}
-std::string Error(const Status &s) { return RESP_PREFIX_ERROR +
StatusToRedisErrorMsg(s) + CRLF; }
+std::string Error(const Status &s) {
+ std::string res;
+ res.reserve(s.Msg().size() + 3); // 1 for '-', 2 for CRLF
Review Comment:
Ok, I've reverted this modification.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]