update cashew and stop building the no-longer-needed istring.cpp
This commit is contained in:
Родитель
5ce5d05031
Коммит
c702b43fda
|
@ -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'),
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#include "istring.h"
|
||||
|
||||
namespace cashew {
|
||||
|
||||
IString::StringSet IString::strings;
|
||||
|
||||
} // namespace cashew
|
||||
|
|
@ -35,8 +35,6 @@ struct IString {
|
|||
return strcmp(x, y) == 0;
|
||||
}
|
||||
};
|
||||
typedef std::unordered_set<const char *, CStringHash, CStringEqual> 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<const char *, CStringHash, CStringEqual> 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;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче