Skip to content

Commit a942549

Browse files
authored
use the const reference for avoiding copy (#704)
1 parent 09921ff commit a942549

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/cluster.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ Status Cluster::ParseClusterNodes(const std::string &nodes_str, ClusterNodes *no
507507
nodes->clear();
508508

509509
// Parse all nodes
510-
for (const auto& node_str : nodes_info) {
510+
for (const auto &node_str : nodes_info) {
511511
std::vector<std::string> fields = Util::Split(node_str, " ");
512512
if (fields.size() < 5) {
513513
return Status(Status::ClusterInvalidInfo, "Invalid cluster nodes info");

src/config.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void Config::initFieldValidator() {
262262
return Status::OK();
263263
}},
264264
};
265-
for (const auto& iter : validators) {
265+
for (const auto &iter : validators) {
266266
auto field_iter = fields_.find(iter.first);
267267
if (field_iter != fields_.end()) {
268268
field_iter->second->validate = iter.second;
@@ -479,7 +479,7 @@ void Config::initFieldCallback() {
479479
{"rocksdb.level0_stop_writes_trigger", set_cf_option_cb},
480480
{"rocksdb.level0_file_num_compaction_trigger", set_cf_option_cb}
481481
};
482-
for (const auto& iter : callbacks) {
482+
for (const auto &iter : callbacks) {
483483
auto field_iter = fields_.find(iter.first);
484484
if (field_iter != fields_.end()) {
485485
field_iter->second->callback = iter.second;

src/server.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Status Server::Start() {
117117
}
118118
}
119119

120-
for (const auto& worker : worker_threads_) {
120+
for (const auto &worker : worker_threads_) {
121121
worker->Start();
122122
}
123123
task_runner_.Start();
@@ -171,7 +171,7 @@ Status Server::Start() {
171171
void Server::Stop() {
172172
stop_ = true;
173173
if (replication_thread_) replication_thread_->Stop();
174-
for (const auto& worker : worker_threads_) {
174+
for (const auto &worker : worker_threads_) {
175175
worker->Stop();
176176
}
177177
DisconnectSlaves();
@@ -180,7 +180,7 @@ void Server::Stop() {
180180
}
181181

182182
void Server::Join() {
183-
for (const auto& worker : worker_threads_) {
183+
for (const auto &worker : worker_threads_) {
184184
worker->Join();
185185
}
186186
task_runner_.Join();

tests/cppunit/rwlock_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
TEST(LockManager, LockKey) {
2828
LockManager locks(8);
2929
std::vector<rocksdb::Slice> keys = {"abc", "123", "456", "abc", "123"};
30-
for (const auto key : keys) {
30+
for (const auto &key : keys) {
3131
locks.Lock(key);
3232
locks.UnLock(key);
3333
}

tests/cppunit/t_string_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TEST_F(RedisStringTest, MGetAndMSet) {
7575
string->MSet(pairs_);
7676
std::vector<Slice> keys;
7777
std::vector<std::string> values;
78-
for (const auto pair : pairs_) {
78+
for (const auto &pair : pairs_) {
7979
keys.emplace_back(pair.key);
8080
}
8181
string->MGet(keys, &values);
@@ -178,7 +178,7 @@ TEST_F(RedisStringTest, MSetNX) {
178178
EXPECT_EQ(1, ret);
179179
std::vector<Slice> keys;
180180
std::vector<std::string> values;
181-
for (const auto pair : pairs_) {
181+
for (const auto &pair : pairs_) {
182182
keys.emplace_back(pair.key);
183183
}
184184
string->MGet(keys, &values);

0 commit comments

Comments
 (0)