PragmaTwice commented on code in PR #3164: URL: https://github.com/apache/kvrocks/pull/3164#discussion_r2331788860
########## src/commands/cmd_timeseries.cc: ########## @@ -126,13 +126,26 @@ std::string FormatCreateRuleResAsRedisReply(TSCreateRuleResult res) { return ""; } +std::string FormatTSLabelListAsRedisReply(const redis::LabelKVList &labels) { + std::vector<std::string> labels_str; + labels_str.reserve(labels.size()); + for (const auto &label : labels) { + auto str = redis::Array( + {redis::BulkString(label.k), label.v.size() ? redis::BulkString(label.v) : redis::NilString(redis::RESP::v3)}); + labels_str.push_back(str); + } + return redis::Array(labels_str); +} + } // namespace namespace redis { class KeywordCommandBase : public Commander { public: - KeywordCommandBase(size_t skip_num, size_t tail_skip_num) : skip_num_(skip_num), tail_skip_num_(tail_skip_num) {} + KeywordCommandBase(size_t skip_num, size_t tail_skip_num) : skip_num_(skip_num), tail_skip_num_(tail_skip_num) { + handlers_.reserve(32); // Avoid Realloc space, or keywords_ may be invalid. Review Comment: Maybe you can try deque instead of vector. deque::push_back will not invalidate element references. -- 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: issues-unsubscr...@kvrocks.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org