Commit 994269dc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #278 from undingen/interpreter_speed

Small performance improvement when interpreting
parents bf63439c 552a3cfc
......@@ -14,6 +14,8 @@
#include "analysis/scoping_analysis.h"
#include "llvm/ADT/DenseSet.h"
#include "core/ast.h"
#include "core/common.h"
#include "core/util.h"
......@@ -112,7 +114,7 @@ struct ScopingAnalysis::ScopeNameUsage {
const std::string* private_name;
ScopingAnalysis* scoping;
typedef std::unordered_set<InternedString> StrSet;
typedef llvm::DenseSet<InternedString> StrSet;
// Properties determined from crawling the scope:
StrSet read;
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
#include <cstdio>
#include <sys/time.h>
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h"
......@@ -78,6 +79,7 @@ public:
friend class InternedStringPool;
friend struct std::hash<InternedString>;
friend struct std::less<InternedString>;
friend struct llvm::DenseMapInfo<pyston::InternedString>;
};
class InternedStringPool {
......@@ -130,4 +132,18 @@ template <> struct less<pyston::InternedString> {
};
}
template <> struct llvm::DenseMapInfo<pyston::InternedString> {
static inline pyston::InternedString getEmptyKey() { return pyston::InternedString(); }
static inline pyston::InternedString getTombstoneKey() {
pyston::InternedString str;
str._str = (const std::string*)-1;
return str;
}
static unsigned getHashValue(const pyston::InternedString& val) { return std::hash<pyston::InternedString>()(val); }
static bool isEqual(const pyston::InternedString& lhs, const pyston::InternedString& rhs) {
// Have to reimplement InternedString comparison otherwise asserts would trigger because of the empty keys.
return lhs._str == rhs._str;
}
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment