deps,shared,frontend-tools: Move obs-scripting to shared folder
This commit is contained in:
parent
ade04f4f1c
commit
f5e2f15d28
32 changed files with 6 additions and 2 deletions
28
shared/obs-scripting/cstrcache.cpp
Normal file
28
shared/obs-scripting/cstrcache.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue