You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by hu...@apache.org on 2022/07/03 05:25:53 UTC

[incubator-kvrocks] branch unstable updated: use the const reference for avoiding copy (#704)

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/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new a942549  use the const reference for avoiding copy (#704)
a942549 is described below

commit a9425497790bdba8ab785aa4ad6e7214049584e9
Author: jakevin <30...@users.noreply.github.com>
AuthorDate: Sun Jul 3 13:25:49 2022 +0800

    use the const reference for avoiding copy (#704)
---
 src/cluster.cc                 | 2 +-
 src/config.cc                  | 4 ++--
 src/server.cc                  | 6 +++---
 tests/cppunit/rwlock_test.cc   | 2 +-
 tests/cppunit/t_string_test.cc | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/cluster.cc b/src/cluster.cc
index 7a6c000..0d5c454 100644
--- a/src/cluster.cc
+++ b/src/cluster.cc
@@ -507,7 +507,7 @@ Status Cluster::ParseClusterNodes(const std::string &nodes_str, ClusterNodes *no
   nodes->clear();
 
   // Parse all nodes
-  for (const auto& node_str : nodes_info) {
+  for (const auto &node_str : nodes_info) {
     std::vector<std::string> fields = Util::Split(node_str, " ");
     if (fields.size() < 5) {
       return Status(Status::ClusterInvalidInfo, "Invalid cluster nodes info");
diff --git a/src/config.cc b/src/config.cc
index e3a7c57..4151620 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -262,7 +262,7 @@ void Config::initFieldValidator() {
         return Status::OK();
       }},
   };
-  for (const auto& iter : validators) {
+  for (const auto &iter : validators) {
     auto field_iter = fields_.find(iter.first);
     if (field_iter != fields_.end()) {
       field_iter->second->validate = iter.second;
@@ -479,7 +479,7 @@ void Config::initFieldCallback() {
       {"rocksdb.level0_stop_writes_trigger", set_cf_option_cb},
       {"rocksdb.level0_file_num_compaction_trigger", set_cf_option_cb}
   };
-  for (const auto& iter : callbacks) {
+  for (const auto &iter : callbacks) {
     auto field_iter = fields_.find(iter.first);
     if (field_iter != fields_.end()) {
       field_iter->second->callback = iter.second;
diff --git a/src/server.cc b/src/server.cc
index 9139a85..9fcc82f 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -117,7 +117,7 @@ Status Server::Start() {
     }
   }
 
-  for (const auto& worker : worker_threads_) {
+  for (const auto &worker : worker_threads_) {
     worker->Start();
   }
   task_runner_.Start();
@@ -171,7 +171,7 @@ Status Server::Start() {
 void Server::Stop() {
   stop_ = true;
   if (replication_thread_) replication_thread_->Stop();
-  for (const auto& worker : worker_threads_) {
+  for (const auto &worker : worker_threads_) {
     worker->Stop();
   }
   DisconnectSlaves();
@@ -180,7 +180,7 @@ void Server::Stop() {
 }
 
 void Server::Join() {
-  for (const auto& worker : worker_threads_) {
+  for (const auto &worker : worker_threads_) {
     worker->Join();
   }
   task_runner_.Join();
diff --git a/tests/cppunit/rwlock_test.cc b/tests/cppunit/rwlock_test.cc
index 4d4d739..4c6ef90 100644
--- a/tests/cppunit/rwlock_test.cc
+++ b/tests/cppunit/rwlock_test.cc
@@ -27,7 +27,7 @@
 TEST(LockManager, LockKey) {
   LockManager locks(8);
   std::vector<rocksdb::Slice> keys = {"abc", "123", "456", "abc", "123"};
-  for (const auto key : keys) {
+  for (const auto &key : keys) {
     locks.Lock(key);
     locks.UnLock(key);
   }
diff --git a/tests/cppunit/t_string_test.cc b/tests/cppunit/t_string_test.cc
index b3d0274..2848d8a 100644
--- a/tests/cppunit/t_string_test.cc
+++ b/tests/cppunit/t_string_test.cc
@@ -75,7 +75,7 @@ TEST_F(RedisStringTest, MGetAndMSet) {
   string->MSet(pairs_);
   std::vector<Slice> keys;
   std::vector<std::string> values;
-  for (const auto pair : pairs_) {
+  for (const auto &pair : pairs_) {
     keys.emplace_back(pair.key);
   }
   string->MGet(keys, &values);
@@ -178,7 +178,7 @@ TEST_F(RedisStringTest, MSetNX) {
   EXPECT_EQ(1, ret);
   std::vector<Slice> keys;
   std::vector<std::string> values;
-  for (const auto pair : pairs_) {
+  for (const auto &pair : pairs_) {
     keys.emplace_back(pair.key);
   }
   string->MGet(keys, &values);