Commit 5c60ed7c authored by Marius Wachtler's avatar Marius Wachtler

microoptimize getIsDefinedName + startswith

parent 38d3b280
......@@ -534,7 +534,7 @@ bool isIsDefinedName(llvm::StringRef name) {
InternedString getIsDefinedName(InternedString name, InternedStringPool& interned_strings) {
// TODO could cache this
return interned_strings.get("!is_defined_" + std::string(name.s()));
return interned_strings.get(("!is_defined_" + name.s()).str());
}
class IRGeneratorImpl : public IRGenerator {
......
......@@ -96,18 +96,6 @@ Timer::~Timer() {
#endif // !DISABLE_TIMERS
bool startswith(const std::string& s, const std::string& pattern) {
if (pattern.size() > s.size())
return false;
return s.compare(0, pattern.size(), pattern) == 0;
}
bool endswith(const std::string& s, const std::string& pattern) {
if (pattern.size() > s.size())
return false;
return s.compare(s.size() - pattern.size(), pattern.size(), pattern) == 0;
}
void removeDirectoryIfExists(const std::string& path) {
llvm_error_code code;
......
......@@ -82,8 +82,13 @@ public:
#endif // #else DISABLE_TIMERS
bool startswith(const std::string& s, const std::string& pattern);
bool endswith(const std::string& s, const std::string& pattern);
inline bool startswith(llvm::StringRef s, llvm::StringRef pattern) {
return s.startswith(pattern);
}
inline bool endswith(llvm::StringRef s, llvm::StringRef pattern) {
return s.endswith(pattern);
}
void removeDirectoryIfExists(const std::string& path);
......
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