Skip to content

Commit

Permalink
Merge pull request #355 from lostystyg/0.20
Browse files Browse the repository at this point in the history
Fixed static initialization order problem
  • Loading branch information
andyoknen authored Aug 11, 2022
2 parents a3d345b + fdbfe37 commit 4284cfa
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 4284cfa

Please sign in to comment.