mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 03:53:07 +01:00
Use EnumMap for format token lookups
This commit is contained in:
@@ -9,13 +9,14 @@
|
||||
|
||||
#include "FormatCodes.h"
|
||||
|
||||
#include "../core/EnumMap.hpp"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
static const std::unordered_map<std::string_view, FormatToken> FormatTokenMap = {
|
||||
static const EnumMap<FormatToken> FormatTokenMap = {
|
||||
{ "MOVE_X", FormatToken::Move, },
|
||||
{ "NEWLINE", FormatToken::Newline, },
|
||||
{ "NEWLINE_SMALLER", FormatToken::NewlineSmall, },
|
||||
@@ -97,13 +98,10 @@ std::string_view FormatTokenToString(FormatToken token, bool withBraces)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& t : FormatTokenMap)
|
||||
{
|
||||
if (t.second == token)
|
||||
{
|
||||
return t.first;
|
||||
}
|
||||
}
|
||||
auto it = FormatTokenMap.find(token);
|
||||
if (it != FormatTokenMap.end())
|
||||
return it->first;
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user