r120013 dropped passing in the precomputed file size to
MemoryBuffer::getFile, causing us to pick up a fstat for
every file. Restore the optimization.
llvm-svn: 120032
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 9572aaad..b884388 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -394,11 +394,12 @@
getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) {
llvm::StringRef Filename = Entry->getName();
if (FileSystemOpts.WorkingDir.empty())
- return llvm::MemoryBuffer::getFile(Filename, ErrorStr);
+ return llvm::MemoryBuffer::getFile(Filename, ErrorStr, Entry->getSize());
llvm::sys::Path FilePath(Filename);
FixupRelativePath(FilePath, FileSystemOpts);
- return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr);
+ return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr,
+ Entry->getSize());
}
llvm::MemoryBuffer *FileManager::
diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp
index 3e13740..738af41 100644
--- a/clang/lib/Basic/FileSystemStatCache.cpp
+++ b/clang/lib/Basic/FileSystemStatCache.cpp
@@ -24,7 +24,6 @@
if (Result == CacheMiss)
Result = ::stat(Path, &StatBuf) ? CacheHitMissing : CacheHitExists;
-
// Do not cache failed stats, it is easy to construct common inconsistent
// situations if we do, and they are not important for PCH performance (which
// currently only needs the stats to construct the initial FileManager