From 1a22e96849c2a92ee5b25a974c0cb37a32321df9 Mon Sep 17 00:00:00 2001 From: SamuelSze1 <131506901+SamuelSze1@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:26:19 +0800 Subject: [PATCH] feat: solve big key problem (#40) --- src/proto_parser.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 src/proto_parser.cc diff --git a/src/proto_parser.cc b/src/proto_parser.cc old mode 100644 new mode 100755 index 8c51c55..c0e7844 --- a/src/proto_parser.cc +++ b/src/proto_parser.cc @@ -25,10 +25,8 @@ void PProtoParser::Reset() { paramLen_ = -1; numOfParam_ = 0; - // Optimize: Most redis command has 3 args - while (params_.size() > 3) { - params_.pop_back(); - } + params_.clear(); + } PParseResult PProtoParser::ParseRequest(const char*& ptr, const char* end) { @@ -98,6 +96,8 @@ PParseResult PProtoParser::parseStrval(const char*& ptr, const char* end, PStrin assert(paramLen_ >= 0); if (static_cast(end - ptr) < paramLen_ + 2) { + paramLen_-=(end-ptr); + result.append(ptr, end - ptr); return PParseResult::kWait; } @@ -106,7 +106,7 @@ PParseResult PProtoParser::parseStrval(const char*& ptr, const char* end, PStrin return PParseResult::kError; } - result.assign(ptr, tail - ptr); + result.append(ptr, tail - ptr); ptr = tail + 2; paramLen_ = -1;