Skip to content

Commit

Permalink
Fixed static initialization order problem
Browse files Browse the repository at this point in the history
  • Loading branch information
lostystyg committed Aug 11, 2022
1 parent a3d345b commit fdbfe37
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/pocketdb/helpers/ShortFormHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
#include <set>


static const std::map<PocketDb::ShortTxType, std::string> typesMap = {
{ PocketDb::ShortTxType::PocketnetTeam, "pocketnetteam" },
{ PocketDb::ShortTxType::Money, "money" },
{ PocketDb::ShortTxType::Referal, "referal" },
{ PocketDb::ShortTxType::Answer, "answer" },
{ PocketDb::ShortTxType::Comment, "comment" },
{ PocketDb::ShortTxType::Subscriber, "subscriber" },
{ PocketDb::ShortTxType::CommentScore, "commentscore" },
{ PocketDb::ShortTxType::ContentScore, "contentscore" },
{ PocketDb::ShortTxType::PrivateContent, "privatecontent" },
{ PocketDb::ShortTxType::Boost, "boost" },
{ PocketDb::ShortTxType::Repost, "repost" },
};
static const std::map<PocketDb::ShortTxType, std::string>& GetTypesMap() {
static const std::map<PocketDb::ShortTxType, std::string> typesMap = {
{ PocketDb::ShortTxType::PocketnetTeam, "pocketnetteam" },
{ PocketDb::ShortTxType::Money, "money" },
{ PocketDb::ShortTxType::Referal, "referal" },
{ PocketDb::ShortTxType::Answer, "answer" },
{ PocketDb::ShortTxType::Comment, "comment" },
{ PocketDb::ShortTxType::Subscriber, "subscriber" },
{ PocketDb::ShortTxType::CommentScore, "commentscore" },
{ PocketDb::ShortTxType::ContentScore, "contentscore" },
{ PocketDb::ShortTxType::PrivateContent, "privatecontent" },
{ PocketDb::ShortTxType::Boost, "boost" },
{ PocketDb::ShortTxType::Repost, "repost" },
};
return typesMap;
}

std::string PocketHelpers::ShortTxTypeConvertor::toString(PocketDb::ShortTxType type)
{
static const auto& typesMap = GetTypesMap();
auto str = typesMap.find(type);
if (str != typesMap.end()) {
return str->second;
Expand All @@ -47,6 +51,7 @@ bool PocketHelpers::ShortTxFilterValidator::Notifications::IsFilterAllowed(Pocke

PocketDb::ShortTxType PocketHelpers::ShortTxTypeConvertor::strToType(const std::string& typeStr)
{
static const auto& typesMap = GetTypesMap();
auto type = std::find_if(typesMap.begin(), typesMap.end(), [&](const auto& elem) { return elem.second == typeStr; });
if (type != typesMap.end()) {
return type->first;
Expand Down

0 comments on commit fdbfe37

Please sign in to comment.