From 2784c458faf92b37285d70cbc196a6bfb23c99bb Mon Sep 17 00:00:00 2001 From: Georges Berenger Date: Mon, 20 May 2024 11:45:54 -0700 Subject: [PATCH] Use unordered_map for RecordableTypeId names Summary: Obvious minor optimization. Reviewed By: hanghu Differential Revision: D57542723 fbshipit-source-id: 32b6f19ea7fcf282f29d522c7d3fa0c3c0857ed6 --- vrs/StreamId.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vrs/StreamId.cpp b/vrs/StreamId.cpp index 56621478..642e0820 100644 --- a/vrs/StreamId.cpp +++ b/vrs/StreamId.cpp @@ -16,8 +16,8 @@ #include "StreamId.h" -#include #include +#include #include @@ -27,8 +27,8 @@ namespace vrs { namespace { -const map& getRecordableTypeIdRegistry() { - static const map sRegistry = { +const unordered_map& getRecordableTypeIdRegistry() { + static const unordered_map sRegistry = { {RecordableTypeId::Undefined, "Undefined"}, {RecordableTypeId::VRSIndex, "VRS Index"}, // should probably not happen {RecordableTypeId::VRSDescription, "VRS Description"}, // should probably not happen @@ -189,7 +189,7 @@ StreamId fromNumericNameWithSeparator(const string& numericName, uint8_t separat } // namespace string toString(RecordableTypeId typeId) { - const map& registry = getRecordableTypeIdRegistry(); + const unordered_map& registry = getRecordableTypeIdRegistry(); auto iter = registry.find(typeId); if (iter != registry.end()) { return iter->second; @@ -198,7 +198,7 @@ string toString(RecordableTypeId typeId) { } bool StreamId::isKnownTypeId(RecordableTypeId typeId) { - const map& registry = getRecordableTypeIdRegistry(); + const unordered_map& registry = getRecordableTypeIdRegistry(); return registry.find(typeId) != registry.end(); }