yolobs-studio/deps/obs-scripting/cstrcache.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
463 B
C++
Raw Permalink Normal View History

2018-02-19 19:54:37 +00:00
#include <unordered_map>
#include <string>
#include "cstrcache.h"
using namespace std;
struct const_string_table {
unordered_map<string, string> strings;
};
static struct const_string_table table;
const char *cstrcache_get(const char *str)
{
if (!str || !*str)
return "";
auto &strings = table.strings;
auto pair = strings.find(str);
if (pair == strings.end()) {
strings[str] = str;
pair = strings.find(str);
}
return pair->second.c_str();
}