[llvm] r176386 - In llvm::MemoryBuffer::getFile() remove an unnecessary stat call check.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Mar 1 14:48:51 PST 2013
Author: akirtzidis
Date: Fri Mar 1 16:48:51 2013
New Revision: 176386
URL: http://llvm.org/viewvc/llvm-project?rev=176386&view=rev
Log:
In llvm::MemoryBuffer::getFile() remove an unnecessary stat call check.
The sys::fs::is_directory() check is unnecessary because, if the filename is
a directory, the function will fail anyway with the same error code returned.
Remove the check to avoid an unnecessary stat call.
Someone needs to review on windows and see if the check is necessary there or not.
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=176386&r1=176385&r2=176386&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Fri Mar 1 16:48:51 2013
@@ -244,6 +244,8 @@ error_code MemoryBuffer::getFile(const c
OwningPtr<MemoryBuffer> &result,
int64_t FileSize,
bool RequiresNullTerminator) {
+ // FIXME: Review if this check is unnecessary on windows as well.
+#ifdef LLVM_ON_WIN32
// First check that the "file" is not a directory
bool is_dir = false;
error_code err = sys::fs::is_directory(Filename, is_dir);
@@ -251,6 +253,7 @@ error_code MemoryBuffer::getFile(const c
return err;
if (is_dir)
return make_error_code(errc::is_a_directory);
+#endif
int OpenFlags = O_RDONLY;
#ifdef O_BINARY
More information about the llvm-commits
mailing list