diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index ad18935e2..82545653a 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -43,7 +43,6 @@ def get_native_optimizer(): for compiler in [shared.CLANG, 'g++', 'clang++']: # try our clang first, otherwise hope for a system compiler in the path shared.logging.debug(' using ' + compiler) out, err = subprocess.Popen([compiler, - shared.path_from_root('tools', 'optimizer', 'istring.cpp'), shared.path_from_root('tools', 'optimizer', 'parser.cpp'), shared.path_from_root('tools', 'optimizer', 'simple_ast.cpp'), shared.path_from_root('tools', 'optimizer', 'optimizer.cpp'), diff --git a/tools/optimizer/istring.cpp b/tools/optimizer/istring.cpp deleted file mode 100644 index cb81dba6b..000000000 --- a/tools/optimizer/istring.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "istring.h" - -namespace cashew { - -IString::StringSet IString::strings; - -} // namespace cashew - diff --git a/tools/optimizer/istring.h b/tools/optimizer/istring.h index 281db08e1..d8cd3cc5e 100644 --- a/tools/optimizer/istring.h +++ b/tools/optimizer/istring.h @@ -35,8 +35,6 @@ struct IString { return strcmp(x, y) == 0; } }; - typedef std::unordered_set StringSet; - static StringSet strings; IString() : str(nullptr) {} IString(const char *s, bool reuse=true) { // if reuse=true, then input is assumed to remain alive; not copied @@ -44,19 +42,22 @@ struct IString { } void set(const char *s, bool reuse=true) { + typedef std::unordered_set StringSet; + static StringSet* strings = new StringSet(); + if (reuse) { - auto result = strings.insert(s); // if already present, does nothing + auto result = strings->insert(s); // if already present, does nothing str = *(result.first); } else { - auto existing = strings.find(s); - if (existing == strings.end()) { + auto existing = strings->find(s); + if (existing == strings->end()) { char *copy = (char*)malloc(strlen(s)+1); // XXX leaked strcpy(copy, s); s = copy; } else { s = *existing; } - strings.insert(s); + strings->insert(s); str = s; } }