summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2016-03-26 18:55:13 +0000
committerBob Wilson <bob.wilson@apple.com>2016-03-26 18:55:13 +0000
commitf43354f69c1f56016a2d7add6155332d866d4a2c (patch)
treeaff95eca2e1416ed3e7860596f9e927469a63857 /clang/lib/Basic/VirtualFileSystem.cpp
parent1460e9f1ca07af1189971429eee76d7c0d086103 (diff)
downloadbcm5719-llvm-f43354f69c1f56016a2d7add6155332d866d4a2c.tar.gz
bcm5719-llvm-f43354f69c1f56016a2d7add6155332d866d4a2c.zip
Check if a path is already absolute before trying to make it so.
The FileSystem::makeAbsolute function has been calculating the current working directory unconditionally, even when it is not needed. This calls down to llvm::sys::fs::current_path, which is relatively expensive because it stats two directories, regardless of whether those paths are already in the stat cache. The net effect is that when using the VFS, every stat during header search turns into three stats. With this change, we get back to a single stat for absolute directory paths. llvm-svn: 264519
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 83400cfcd7d..325e5eb7bb7 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -100,6 +100,9 @@ FileSystem::getBufferForFile(const llvm::Twine &Name, int64_t FileSize,
}
std::error_code FileSystem::makeAbsolute(SmallVectorImpl<char> &Path) const {
+ if (llvm::sys::path::is_absolute(Path))
+ return std::error_code();
+
auto WorkingDir = getCurrentWorkingDirectory();
if (!WorkingDir)
return WorkingDir.getError();
OpenPOWER on IntegriCloud