This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 5ace37dd chore: use `StringJoin` in `EnumField::Set` (#2485)
5ace37dd is described below

commit 5ace37dd3ece35511c045ec79e0f756e3fabfdbc
Author: Twice <[email protected]>
AuthorDate: Sat Aug 10 15:07:30 2024 +0800

    chore: use `StringJoin` in `EnumField::Set` (#2485)
---
 src/commands/cmd_hll.cc  | 6 +++---
 src/config/config_type.h | 7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/commands/cmd_hll.cc b/src/commands/cmd_hll.cc
index d464e131..328ab45e 100644
--- a/src/commands/cmd_hll.cc
+++ b/src/commands/cmd_hll.cc
@@ -35,7 +35,7 @@ class CommandPfAdd final : public Commander {
  public:
   Status Execute(Server *srv, Connection *conn, std::string *output) override {
     redis::HyperLogLog hll(srv->storage, conn->GetNamespace());
-    DCHECK_GE(args_.size(), 2);
+    DCHECK_GE(args_.size(), 2u);
     std::vector<uint64_t> hashes(args_.size() - 2);
     for (size_t i = 2; i < args_.size(); i++) {
       hashes[i - 2] = redis::HyperLogLog::HllHash(args_[i]);
@@ -60,7 +60,7 @@ class CommandPfCount final : public Commander {
     uint64_t ret{};
     rocksdb::Status s;
     // The first argument is the command name, so we need to skip it.
-    DCHECK_GE(args_.size(), 2);
+    DCHECK_GE(args_.size(), 2u);
     if (args_.size() > 2) {
       std::vector<Slice> keys(args_.begin() + 1, args_.end());
       s = hll.CountMultiple(keys, &ret);
@@ -84,7 +84,7 @@ class CommandPfCount final : public Commander {
 class CommandPfMerge final : public Commander {
   Status Execute(Server *srv, Connection *conn, std::string *output) override {
     redis::HyperLogLog hll(srv->storage, conn->GetNamespace());
-    DCHECK_GT(args_.size(), 1);
+    DCHECK_GT(args_.size(), 1u);
     std::vector<Slice> src_user_keys(args_.begin() + 2, args_.end());
     auto s = hll.Merge(/*dest_user_key=*/args_[1], src_user_keys);
     if (!s.ok() && !s.IsNotFound()) {
diff --git a/src/config/config_type.h b/src/config/config_type.h
index 299e1459..36fa3799 100644
--- a/src/config/config_type.h
+++ b/src/config/config_type.h
@@ -233,12 +233,7 @@ class EnumField : public ConfigField {
       }
     }
 
-    auto acceptable_values =
-        std::accumulate(enums_.begin(), enums_.end(), std::string{}, 
[this](const std::string &res, const EnumItem &e) {
-          if (&e != &enums_.back()) return res + "'" + e.name + "', ";
-
-          return res + "'" + e.name + "'";
-        });
+    auto acceptable_values = util::StringJoin(enums_, [](const auto &e) { 
return fmt::format("'{}'", e.name); });
     return {Status::NotOK, fmt::format("invalid enum option, acceptable values 
are {}", acceptable_values)};
   }
 

Reply via email to