Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
This commit is contained in:
@@ -176,7 +176,7 @@ JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const {
|
||||
|
||||
std::string Error;
|
||||
llvm::raw_string_ostream ES(Error);
|
||||
StringRef Match = MatchTrie.findEquivalent(NativeFilePath.str(), ES);
|
||||
StringRef Match = MatchTrie.findEquivalent(NativeFilePath, ES);
|
||||
if (Match.empty())
|
||||
return std::vector<CompileCommand>();
|
||||
llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator
|
||||
@@ -307,13 +307,13 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
|
||||
SmallString<128> AbsolutePath(
|
||||
Directory->getValue(DirectoryStorage));
|
||||
llvm::sys::path::append(AbsolutePath, FileName);
|
||||
llvm::sys::path::native(AbsolutePath.str(), NativeFilePath);
|
||||
llvm::sys::path::native(AbsolutePath, NativeFilePath);
|
||||
} else {
|
||||
llvm::sys::path::native(FileName, NativeFilePath);
|
||||
}
|
||||
IndexByFile[NativeFilePath].push_back(
|
||||
CompileCommandRef(Directory, Command));
|
||||
MatchTrie.insert(NativeFilePath.str());
|
||||
MatchTrie.insert(NativeFilePath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user