phosphor-ipmi-flash: Code Health Cleanup
Removed the following warning.
- using decl '*' is unused
- 'push_back' is called inside a loop; consider pre-allocating the
container capacity before the loop
- function '*' defined in a header file; function
definitions in header files can lead to ODR violations
Change-Id: I44e4b0f8056a853fb45b690394be1a8ebec45b20
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/bmc/firmware-handler/firmware_handler.cpp b/bmc/firmware-handler/firmware_handler.cpp
index afcfc81..9268809 100644
--- a/bmc/firmware-handler/firmware_handler.cpp
+++ b/bmc/firmware-handler/firmware_handler.cpp
@@ -56,10 +56,10 @@
}
std::vector<std::string> blobs;
- for (const auto& item : firmwares)
- {
- blobs.push_back(item.blobName);
- }
+ blobs.reserve(firmwares.size());
+ std::for_each(
+ firmwares.begin(), firmwares.end(),
+ [&blobs](const auto& blob) { blobs.emplace_back(blob.blobName); });
if (0 == std::count(blobs.begin(), blobs.end(), hashBlobId))
{