diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-29 19:11:22 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-29 19:11:22 +0000 |
| commit | 1ea733db9d7eb1e55785e9b2201638c37db56cad (patch) | |
| tree | 0a4374c16d13d274a4f4ebbc3dc3180a1a24688d /lib/System/Unix | |
| parent | 8475ec068c213d0bf73f7686d82491a8f12e3b32 (diff) | |
| download | external_llvm-1ea733db9d7eb1e55785e9b2201638c37db56cad.zip external_llvm-1ea733db9d7eb1e55785e9b2201638c37db56cad.tar.gz external_llvm-1ea733db9d7eb1e55785e9b2201638c37db56cad.tar.bz2 | |
Use the stat information in the Path object, if it is already obtained. This
avoids a call to ::fstat by MappedFile when the file size information was
already obtained by the Path object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35477 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
| -rw-r--r-- | lib/System/Unix/MappedFile.inc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc index 4dccd13..5e76e2b 100644 --- a/lib/System/Unix/MappedFile.inc +++ b/lib/System/Unix/MappedFile.inc @@ -54,15 +54,14 @@ bool MappedFile::initialize(std::string* ErrMsg) { MakeErrMsg(ErrMsg, "can't open file '" + path_.toString() + "'"); return true; } - struct stat sbuf; - if(::fstat(FD, &sbuf) < 0) { - MakeErrMsg(ErrMsg, "can't stat file '"+ path_.toString() + "'"); + const FileStatus *Status = path_.getFileStatus(false, ErrMsg); + if (!Status) { ::close(FD); return true; } info_ = new MappedFileInfo; info_->FD = FD; - info_->Size = sbuf.st_size; + info_->Size = Status->getSize(); return false; } |
