version-handler: Refactor maps to simplify accesses
This reduces the number of map lookups needed for read() and close()
operations and the number of stored strings by referencing the pinned
blobId.
Change-Id: I8c6af5749b8cc8415eedeba484bf4a39a98f0286
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/bmc/version-handler/version_handler.hpp b/bmc/version-handler/version_handler.hpp
index ad380b8..891977d 100644
--- a/bmc/version-handler/version_handler.hpp
+++ b/bmc/version-handler/version_handler.hpp
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <string>
+#include <string_view>
#include <unordered_map>
#include <vector>
@@ -68,13 +69,13 @@
private:
struct BlobInfo
{
- std::string blobId;
+ Pinned<std::string> blobId;
std::unique_ptr<ActionPack> actions;
std::unique_ptr<ImageHandlerInterface> handler;
blobs::StateFlags blobState = static_cast<blobs::StateFlags>(0);
};
- std::unordered_map<std::string, BlobInfo> blobInfoMap;
- std::unordered_map<uint16_t, std::string> sessionToBlob;
+ std::unordered_map<std::string_view, std::unique_ptr<BlobInfo>> blobInfoMap;
+ std::unordered_map<uint16_t, BlobInfo*> sessionToBlob;
};
} // namespace ipmi_flash