[help_text] fix static init issue

pull/1249/head
Tim Stack 2 months ago
parent c497dc49f1
commit 884e6b7415

@ -104,10 +104,18 @@ help_text::with_prql_path(
return *this; return *this;
} }
std::multimap<std::string, help_text*>&
help_text::tag_map()
{
static std::multimap<std::string, help_text*> retval;
return retval;
}
void void
help_text::index_tags() help_text::index_tags()
{ {
for (const auto& tag : this->ht_tags) { for (const auto& tag : this->ht_tags) {
TAGGED.insert(std::make_pair(tag, this)); tag_map().insert(std::make_pair(tag, this));
} }
} }

@ -250,7 +250,7 @@ struct help_text {
void index_tags(); void index_tags();
static std::multimap<std::string, help_text*> TAGGED; static std::multimap<std::string, help_text*>& tag_map();
}; };
#endif #endif

@ -42,15 +42,13 @@
using namespace lnav::roles::literals; using namespace lnav::roles::literals;
std::multimap<std::string, help_text*> help_text::TAGGED;
static std::vector<help_text*> static std::vector<help_text*>
get_related(const help_text& ht) get_related(const help_text& ht)
{ {
std::vector<help_text*> retval; std::vector<help_text*> retval;
for (const auto& tag : ht.ht_tags) { for (const auto& tag : ht.ht_tags) {
auto tagged = help_text::TAGGED.equal_range(tag); auto tagged = help_text::tag_map().equal_range(tag);
for (auto tag_iter = tagged.first; tag_iter != tagged.second; for (auto tag_iter = tagged.first; tag_iter != tagged.second;
++tag_iter) ++tag_iter)

Loading…
Cancel
Save