Skip to content

Commit c882ca6

Browse files
committed
Replace insert with emplace, replace for with foreach
1 parent 974742a commit c882ca6

File tree

1 file changed

+4
-7
lines changed
  • ydb/library/yql/providers/generic/connector/libcpp

1 file changed

+4
-7
lines changed

Diff for: ydb/library/yql/providers/generic/connector/libcpp/client.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,15 @@ namespace NYql::NConnector {
328328

329329
for (auto c : config.GetConnectors()) {
330330
auto cfg = ConnectorConfigToGrpcConfig(c, count++);
331-
auto f = CreateFactoryForConnector(c.GetFactory(), GrpcClient_, cfg, keepAlive);
331+
std::shared_ptr<IConnectionFactory<NApi::Connector>> f
332+
= std::move(CreateFactoryForConnector(c.GetFactory(), GrpcClient_, cfg, keepAlive));
332333

333-
for (size_t i = 0; i < c.ForKindsSize(); ++i) {
334-
auto k = c.GetForKinds(i);
335-
336-
if (FactoryForKind_.contains(k)) {
334+
for (auto k : c.GetForKinds()) {
335+
if (!FactoryForKind_.try_emplace(NYql::EGenericDataSourceKind(k), f).second) {
337336
throw yexception()
338337
<< "Duplicate connector is provided for the kind: "
339338
<< EGenericDataSourceKind_Name(k);
340339
}
341-
342-
FactoryForKind_.insert({k, std::move(f)});
343340
}
344341
}
345342
}

0 commit comments

Comments
 (0)