Skip to content

Commit 57624be

Browse files
mattBorosEvergreen Agent
authored andcommitted
SERVER-77158 apply performance-move-const-arg clang tidy rule for replication
1 parent e7760aa commit 57624be

13 files changed

+32
-30
lines changed

src/mongo/db/repl/hello_response.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,24 +533,24 @@ void HelloResponse::setReplSetVersion(long long version) {
533533
_setVersion = version;
534534
}
535535

536-
void HelloResponse::addHost(const HostAndPort& host) {
536+
void HelloResponse::addHost(HostAndPort host) {
537537
_hostsSet = true;
538-
_hosts.push_back(host);
538+
_hosts.push_back(std::move(host));
539539
}
540540

541-
void HelloResponse::addPassive(const HostAndPort& passive) {
541+
void HelloResponse::addPassive(HostAndPort passive) {
542542
_passivesSet = true;
543-
_passives.push_back(passive);
543+
_passives.push_back(std::move(passive));
544544
}
545545

546-
void HelloResponse::addArbiter(const HostAndPort& arbiter) {
546+
void HelloResponse::addArbiter(HostAndPort arbiter) {
547547
_arbitersSet = true;
548-
_arbiters.push_back(arbiter);
548+
_arbiters.push_back(std::move(arbiter));
549549
}
550550

551-
void HelloResponse::setPrimary(const HostAndPort& primary) {
551+
void HelloResponse::setPrimary(HostAndPort primary) {
552552
_primarySet = true;
553-
_primary = primary;
553+
_primary = std::move(primary);
554554
}
555555

556556
void HelloResponse::setIsArbiterOnly(bool arbiterOnly) {
@@ -587,9 +587,9 @@ void HelloResponse::addTag(const std::string& tagKey, const std::string& tagValu
587587
_tags[tagKey] = tagValue;
588588
}
589589

590-
void HelloResponse::setMe(const HostAndPort& me) {
590+
void HelloResponse::setMe(HostAndPort me) {
591591
_meSet = true;
592-
_me = me;
592+
_me = std::move(me);
593593
}
594594

595595
void HelloResponse::setElectionId(const OID& electionId) {

src/mongo/db/repl/hello_response.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ class HelloResponse {
217217

218218
void setReplSetVersion(long long version);
219219

220-
void addHost(const HostAndPort& host);
220+
void addHost(HostAndPort host);
221221

222-
void addPassive(const HostAndPort& passive);
222+
void addPassive(HostAndPort passive);
223223

224-
void addArbiter(const HostAndPort& arbiter);
224+
void addArbiter(HostAndPort arbiter);
225225

226-
void setPrimary(const HostAndPort& primary);
226+
void setPrimary(HostAndPort primary);
227227

228228
void setIsArbiterOnly(bool arbiterOnly);
229229

@@ -239,7 +239,7 @@ class HelloResponse {
239239

240240
void addTag(const std::string& tagKey, const std::string& tagValue);
241241

242-
void setMe(const HostAndPort& me);
242+
void setMe(HostAndPort me);
243243

244244
void setElectionId(const OID& electionId);
245245

src/mongo/db/repl/noop_writer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ class NoopWriter::PeriodicNoopRunner {
8787
using NoopWriteFn = std::function<void(OperationContext*)>;
8888

8989
public:
90-
PeriodicNoopRunner(Seconds waitTime, NoopWriteFn noopWrite)
91-
: _thread([this, noopWrite, waitTime] { run(waitTime, std::move(noopWrite)); }) {}
90+
PeriodicNoopRunner(const Seconds& waitTime, NoopWriteFn&& noopWrite)
91+
: _thread([this, noopWrite = std::move(noopWrite), waitTime]() mutable {
92+
run(waitTime, std::move(noopWrite));
93+
}) {}
9294

9395
~PeriodicNoopRunner() {
9496
stdx::unique_lock<Latch> lk(_mutex);
@@ -99,7 +101,7 @@ class NoopWriter::PeriodicNoopRunner {
99101
}
100102

101103
private:
102-
void run(Seconds waitTime, NoopWriteFn noopWrite) {
104+
void run(const Seconds& waitTime, NoopWriteFn&& noopWrite) {
103105
Client::initThread("NoopWriter");
104106

105107
while (true) {

src/mongo/db/repl/oplog_applier_impl_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,13 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantAcrossTenantsRequ
828828
}
829829

830830
OplogEntry makeInvalidateOp(OpTime opTime,
831-
NamespaceString nss,
831+
const NamespaceString& nss,
832832
BSONObj document,
833833
OperationSessionInfo sessionInfo,
834834
mongo::UUID uuid) {
835835
return DurableOplogEntry(opTime, // optime
836836
OpTypeEnum::kUpdate, // opType
837-
std::move(nss), // namespace
837+
nss, // namespace
838838
uuid, // uuid
839839
boost::none, // fromMigrate
840840
boost::none, // checkExistenceForDiffInsert

src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ OplogEntry makeOplogEntry(OpTime opTime,
491491
boost::optional<RetryImageEnum> needsRetryImage) {
492492
return {DurableOplogEntry(opTime, // optime
493493
opType, // opType
494-
std::move(nss), // namespace
494+
nss, // namespace
495495
uuid, // uuid
496496
fromMigrate, // fromMigrate
497497
boost::none, // checkExistenceForDiffInsert

src/mongo/db/repl/oplog_entry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ReplOperation : public DurableReplOperation {
117117
static ReplOperation parseOwned(const IDLParserContext& ctxt, const BSONObj&& bsonObject) {
118118
ReplOperation o;
119119
o.parseProtected(ctxt, bsonObject);
120-
o.setAnchor(std::move(bsonObject));
120+
o.setAnchor(bsonObject);
121121
return o;
122122
}
123123

src/mongo/db/repl/oplog_fetcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ AggregateCommandRequest OplogFetcher::_makeAggregateCommandRequest(long long max
594594
BSONObjBuilder secondMatchBuilder(BSON("ts" << BSON("$gte" << startTs)));
595595
stages.emplace_back(DocumentSourceMatch::createFromBson(
596596
Document{{"$match", Document{secondMatchBuilder.obj()}}}.toBson().firstElement(), expCtx));
597-
const auto serializedPipeline = Pipeline::create(std::move(stages), expCtx)->serializeToBson();
597+
auto serializedPipeline = Pipeline::create(std::move(stages), expCtx)->serializeToBson();
598598

599599
AggregateCommandRequest aggRequest(_nss, std::move(serializedPipeline));
600600
aggRequest.setReadConcern(_config.queryReadConcern.toBSONInner());

src/mongo/db/repl/primary_only_service.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,14 @@ std::shared_ptr<PrimaryOnlyService::Instance> PrimaryOnlyService::_insertNewInst
805805
instance,
806806
scopedExecutor = _scopedExecutor,
807807
token = instanceSource.token(),
808-
instanceID] {
808+
instanceID]() mutable {
809809
LOGV2_DEBUG(5123002,
810810
3,
811811
"Starting instance of PrimaryOnlyService",
812812
"service"_attr = serviceName,
813813
"instanceID"_attr = instanceID);
814814

815-
return instance->run(std::move(scopedExecutor), std::move(token));
815+
return instance->run(std::move(scopedExecutor), token);
816816
})
817817
// TODO SERVER-61717 remove this error handler once instance are automatically released
818818
// at the end of run()

src/mongo/db/repl/replication_coordinator_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorImpl::awaitRepli
21312131
"allDurable"_attr = _storage->getAllDurableTimestamp(_service),
21322132
"progress"_attr = _getReplicationProgress(lock));
21332133
}
2134-
return {std::move(status), duration_cast<Milliseconds>(timer.elapsed())};
2134+
return {status, duration_cast<Milliseconds>(timer.elapsed())};
21352135
}
21362136

21372137
SharedSemiFuture<void> ReplicationCoordinatorImpl::awaitReplicationAsyncNoWTimeout(

src/mongo/db/repl/shard_merge_recipient_service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ void ShardMergeRecipientService::Instance::_keepBackupCursorAlive(const Cancella
12231223
executor::RemoteCommandRequest getMoreRequest(
12241224
_client->getServerHostAndPort(),
12251225
nss.dbName(),
1226-
std::move(BSON("getMore" << cursorId << "collection" << nss.coll().toString())),
1226+
BSON("getMore" << cursorId << "collection" << nss.coll().toString()),
12271227
nullptr);
12281228
getMoreRequest.options.fireAndForget = true;
12291229

0 commit comments

Comments
 (0)