[SourceKit] Remove some dupliate computation of realpaths

This commit is contained in:
Alex Hoppen
2021-11-30 22:30:12 +01:00
parent 5f4b1a0b27
commit dcbedc65fd
3 changed files with 23 additions and 10 deletions

View File

@@ -245,14 +245,18 @@ SwiftEditorDocumentFileMap::getByUnresolvedName(StringRef FilePath) {
}
SwiftEditorDocumentRef
SwiftEditorDocumentFileMap::findByPath(StringRef FilePath) {
SwiftEditorDocumentFileMap::findByPath(StringRef FilePath, bool IsRealpath) {
SwiftEditorDocumentRef EditorDoc;
std::string ResolvedPath = SwiftLangSupport::resolvePathSymlinks(FilePath);
std::string Scratch;
if (!IsRealpath) {
Scratch = SwiftLangSupport::resolvePathSymlinks(FilePath);
FilePath = Scratch;
}
Queue.dispatchSync([&]{
for (auto &Entry : Docs) {
if (Entry.getKey() == FilePath ||
Entry.getValue().ResolvedPath == ResolvedPath) {
Entry.getValue().ResolvedPath == FilePath) {
EditorDoc = Entry.getValue().DocRef;
break;
}