From ff86062fdd13b3626267b03f06d6cd121244c96f Mon Sep 17 00:00:00 2001 From: MaheshMadushan Date: Mon, 15 Jan 2024 07:17:28 +0000 Subject: [PATCH] clang formatting issue fixes --- src/commands/cmd_zset.cc | 16 ++++------------ src/types/redis_zset.cc | 9 ++++----- tests/cppunit/types/zset_test.cc | 9 ++++----- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/commands/cmd_zset.cc b/src/commands/cmd_zset.cc index 0109a6820d3..1b8ee64c360 100644 --- a/src/commands/cmd_zset.cc +++ b/src/commands/cmd_zset.cc @@ -1357,7 +1357,6 @@ class CommandZScan : public CommandSubkeyScanBase { } }; - class CommandZDiff : public Commander { public: Status Parse(const std::vector &args) override { @@ -1406,9 +1405,9 @@ class CommandZDiff : public Commander { } protected: - size_t numkeys_ {0}; + size_t numkeys_ = 0; std::vector keys_; - bool with_scores_ {false}; + bool with_scores_ = false; }; class CommandZDiffStore : public Commander { @@ -1426,12 +1425,6 @@ class CommandZDiffStore : public Commander { j++; } - if (auto i = 2 + numkeys_; i < args.size()) { - if (util::ToLower(args[i]) == "withscores") { - with_scores_ = true; - } - } - return Commander::Parse(args); } @@ -1453,9 +1446,8 @@ class CommandZDiffStore : public Commander { } protected: - size_t numkeys_ {0}; + size_t numkeys_ = 0; std::vector keys_; - bool with_scores_ {false}; }; REDIS_REGISTER_COMMANDS(MakeCmdAttr("zadd", -4, "write", 1, 1, 1), @@ -1489,7 +1481,7 @@ REDIS_REGISTER_COMMANDS(MakeCmdAttr("zadd", -4, "write", 1, 1, 1), MakeCmdAttr("zmscore", -3, "read-only", 1, 1, 1), MakeCmdAttr("zscan", -3, "read-only", 1, 1, 1), MakeCmdAttr("zunionstore", -4, "write", CommandZUnionStore::Range), - MakeCmdAttr("zunion", -3, "read-only", CommandZUnion::Range), + MakeCmdAttr("zunion", -3, "read-only", CommandZUnion::Range), MakeCmdAttr("zdiff", -3, "read-only", CommandZDiff::Range), MakeCmdAttr("zdiffstore", -3, "read-only", CommandZDiffStore::Range), ) diff --git a/src/types/redis_zset.cc b/src/types/redis_zset.cc index 389823fab73..d231c5a3a62 100644 --- a/src/types/redis_zset.cc +++ b/src/types/redis_zset.cc @@ -851,7 +851,6 @@ rocksdb::Status ZSet::MGet(const Slice &user_key, const std::vector &memb return rocksdb::Status::OK(); } - rocksdb::Status ZSet::Diff(const std::vector &keys, MemberScores *members) { std::vector lock_keys; lock_keys.reserve(keys.size()); @@ -864,14 +863,14 @@ rocksdb::Status ZSet::Diff(const std::vector &keys, MemberScores *members members->clear(); MemberScores source_member_scores; RangeScoreSpec spec; - uint64_t size {0}; + uint64_t size = 0; auto s = RangeByScore(keys[0], spec, &source_member_scores, &size); if (!s.ok()) return s; - std::map exclude_members {}; - MemberScores target_member_scores {}; + std::map exclude_members; + MemberScores target_member_scores; for (size_t i = 1; i < keys.size(); i++) { - uint64_t size {0}; + uint64_t size = 0; s = RangeByScore(keys[i], spec, &target_member_scores, &size); if (!s.ok()) return s; for (const auto &member_score : target_member_scores) { diff --git a/tests/cppunit/types/zset_test.cc b/tests/cppunit/types/zset_test.cc index 71d5029afee..a69a1ec7776 100644 --- a/tests/cppunit/types/zset_test.cc +++ b/tests/cppunit/types/zset_test.cc @@ -434,18 +434,17 @@ TEST_F(RedisZSetTest, Rank) { auto s = zset_->Del(key_); } - TEST_F(RedisZSetTest, Diff) { uint64_t ret = 0; std::string k1 = "key1"; - std::vector k1_mscores {{"a", -100.1}, {"b", -100.1}, {"c", 0}, {"d", 1.234}}; + std::vector k1_mscores = {{"a", -100.1}, {"b", -100.1}, {"c", 0}, {"d", 1.234}}; std::string k2 = "key2"; - std::vector k2_mscores {{"c", -150.1}}; + std::vector k2_mscores = {{"c", -150.1}}; std::string k3 = "key3"; - std::vector k3_mscores {{"a", -1000.1}, {"c", -100.1}, {"e", 8000.9}}; + std::vector k3_mscores = {{"a", -1000.1}, {"c", -100.1}, {"e", 8000.9}}; auto s = zset_->Add(k1, ZAddFlags::Default(), &k1_mscores, &ret); EXPECT_EQ(ret, 4); @@ -458,7 +457,7 @@ TEST_F(RedisZSetTest, Diff) { zset_->Diff({k1, k2, k3}, &mscores); EXPECT_EQ(2, mscores.size()); - std::vector expected_mscores {{"b", -100.1}, {"d", 1.234}}; + std::vector expected_mscores = {{"b", -100.1}, {"d", 1.234}}; int index = 0; for (auto mscore : expected_mscores) { EXPECT_EQ(mscore.member, mscores[index].member);