X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Ftag.cpp;h=84eb074a4361c9d9a4888d861266f802ba778b78;hp=538190f836fb66782e03a510d0ed2f758a15057d;hb=HEAD;hpb=3a6eb030fb4eca4c2a317f270704fddf31613130 diff --git a/source/core/tag.cpp b/source/core/tag.cpp index 538190f8..84eb074a 100644 --- a/source/core/tag.cpp +++ b/source/core/tag.cpp @@ -9,7 +9,11 @@ using namespace std; namespace { #ifdef DEBUG -map tag_names; +map &get_tag_names() +{ + static map names; + return names; +} #endif } @@ -18,28 +22,29 @@ namespace Msp { namespace GL { Tag::Tag(const char *s): - id((s && *s) ? hash32(s, strlen(s)) : 0) + id((s && *s) ? hash<32>(s, strlen(s)) : 0) { #ifdef DEBUG if(s) - tag_names.insert(make_pair(*this, string(s))); + get_tag_names().insert(make_pair(*this, string(s))); #endif } Tag::Tag(const string &s): - id(s.empty() ? 0 : hash32(s)) + id(s.empty() ? 0 : hash<32>(s)) { #ifdef DEBUG if(!s.empty()) - tag_names.insert(make_pair(*this, s)); + get_tag_names().insert(make_pair(*this, s)); #endif } string Tag::str() const { #ifdef DEBUG - map::const_iterator i=tag_names.find(*this); - if(i!=tag_names.end()) + const auto &names = get_tag_names(); + auto i = names.find(*this); + if(i!=names.end()) return i->second; #endif return format("Tag(%d)", id);