use emplace where appropriate per clang-tidy
The clang-tidy warning 'modernize-use-emplace' correctly flags a
few places where emplace should be used over push.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6ca79285a87d6927e718345dc8dce0387e6b1eda
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index fcc6531..1592d50 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -280,7 +280,7 @@
if (requestDataQueue.size() <= maxReqQueueSize)
{
- requestDataQueue.push(std::pair(id, data));
+ requestDataQueue.emplace(id, data);
checkQueue(true);
}
else
diff --git a/redfish-core/lib/aggregation_service.hpp b/redfish-core/lib/aggregation_service.hpp
index 1cd2e68..83953fd 100644
--- a/redfish-core/lib/aggregation_service.hpp
+++ b/redfish-core/lib/aggregation_service.hpp
@@ -81,7 +81,7 @@
member["@odata.id"] =
crow::utility::urlFromPieces("redfish", "v1", "AggregationService",
"AggregationSources", sat.first);
- members.push_back(std::move(member));
+ members.emplace_back(std::move(member));
}
asyncResp->res.jsonValue["Members@odata.count"] = members.size();
asyncResp->res.jsonValue["Members"] = std::move(members);
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index dcbff2d..4e030d2 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -427,7 +427,7 @@
replace["target"] =
"/redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate";
nlohmann::json::array_t allowed;
- allowed.push_back("PEM");
+ allowed.emplace_back("PEM");
replace["CertificateType@Redfish.AllowableValues"] = std::move(allowed);
actions["#CertificateService.GenerateCSR"]["target"] =
"/redfish/v1/CertificateService/Actions/CertificateService.GenerateCSR";
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index c64d27c..dc6afd8 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -453,14 +453,14 @@
nlohmann::json::array_t computerSystems;
nlohmann::json::object_t system;
system["@odata.id"] = "/redfish/v1/Systems/system";
- computerSystems.push_back(std::move(system));
+ computerSystems.emplace_back(std::move(system));
asyncResp->res.jsonValue["Links"]["ComputerSystems"] =
std::move(computerSystems);
nlohmann::json::array_t managedBy;
nlohmann::json::object_t manager;
manager["@odata.id"] = "/redfish/v1/Managers/bmc";
- managedBy.push_back(std::move(manager));
+ managedBy.emplace_back(std::move(manager));
asyncResp->res.jsonValue["Links"]["ManagedBy"] =
std::move(managedBy);
getChassisState(asyncResp);
@@ -748,9 +748,9 @@
parameter["Required"] = true;
parameter["DataType"] = "String";
nlohmann::json::array_t allowed;
- allowed.push_back("PowerCycle");
+ allowed.emplace_back("PowerCycle");
parameter["AllowableValues"] = std::move(allowed);
- parameters.push_back(std::move(parameter));
+ parameters.emplace_back(std::move(parameter));
asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
}
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index e524145..ec59140 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -825,7 +825,7 @@
nlohmann::json::array_t managedBy;
nlohmann::json::object_t manager;
manager["@odata.id"] = "/redfish/v1/Managers/bmc";
- managedBy.push_back(std::move(manager));
+ managedBy.emplace_back(std::move(manager));
asyncResp->res.jsonValue["Links"]["ManagedBy"] = std::move(managedBy);
asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
"/redfish/v1/Systems/hypervisor/EthernetInterfaces";
@@ -998,9 +998,9 @@
parameter["Required"] = true;
parameter["DataType"] = "String";
nlohmann::json::array_t allowed;
- allowed.push_back("On");
+ allowed.emplace_back("On");
parameter["AllowableValues"] = std::move(allowed);
- parameters.push_back(std::move(parameter));
+ parameters.emplace_back(std::move(parameter));
asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
});
}
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 134ecb6..1319eca 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -259,12 +259,12 @@
parameter["DataType"] = "String";
nlohmann::json::array_t allowableValues;
- allowableValues.push_back("GracefulRestart");
- allowableValues.push_back("ForceRestart");
+ allowableValues.emplace_back("GracefulRestart");
+ allowableValues.emplace_back("ForceRestart");
parameter["AllowableValues"] = std::move(allowableValues);
nlohmann::json::array_t parameters;
- parameters.push_back(std::move(parameter));
+ parameters.emplace_back(std::move(parameter));
asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
});
@@ -1992,7 +1992,7 @@
nlohmann::json::array_t managerForServers;
nlohmann::json::object_t manager;
manager["@odata.id"] = "/redfish/v1/Systems/system";
- managerForServers.push_back(std::move(manager));
+ managerForServers.emplace_back(std::move(manager));
asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
std::move(managerForServers);
@@ -2026,7 +2026,7 @@
boost::urls::url chassiUrl = crow::utility::urlFromPieces(
"redfish", "v1", "Chassis", chassisId);
managerObj["@odata.id"] = chassiUrl;
- managerForChassis.push_back(std::move(managerObj));
+ managerForChassis.emplace_back(std::move(managerObj));
aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
std::move(managerForChassis);
aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index 907f6cf..ce147a8 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -120,7 +120,7 @@
asyncResp->res.jsonValue["Id"] = header->registryPrefix;
asyncResp->res.jsonValue["Registry"] = header->id;
nlohmann::json::array_t languages;
- languages.push_back("en");
+ languages.emplace_back("en");
asyncResp->res.jsonValue["Languages@odata.count"] = languages.size();
asyncResp->res.jsonValue["Languages"] = std::move(languages);
nlohmann::json::array_t locationMembers;
diff --git a/redfish-core/lib/redfish_v1.hpp b/redfish-core/lib/redfish_v1.hpp
index a9b81e4..b3174fb 100644
--- a/redfish-core/lib/redfish_v1.hpp
+++ b/redfish-core/lib/redfish_v1.hpp
@@ -88,7 +88,7 @@
nlohmann::json::object_t member;
member["@odata.id"] = crow::utility::urlFromPieces(
"redfish", "v1", "JsonSchemas", schema);
- members.push_back(std::move(member));
+ members.emplace_back(std::move(member));
}
json["Members"] = std::move(members);
json["Members@odata.count"] = schemas.size();
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index cb27075..7bec478 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -107,7 +107,7 @@
trigger["Severity"] = severity;
trigger["DwellTime"] = *duration;
trigger["Value"] = value;
- triggers.push_back(std::move(trigger));
+ triggers.emplace_back(std::move(trigger));
}
return {std::move(triggers)};
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index b435829..5f80246 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -1796,8 +1796,8 @@
ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
ret["Message"] = std::move(msg);
nlohmann::json::array_t args;
- args.push_back(arg1);
- args.push_back(arg2);
+ args.emplace_back(arg1);
+ args.emplace_back(arg2);
ret["MessageArgs"] = std::move(args);
ret["MessageSeverity"] = "Warning";
ret["Resolution"] = "None.";