Use the stat information in the Path object, if it is already obtained. This
authorReid Spencer <rspencer@reidspencer.com>
Thu, 29 Mar 2007 19:11:22 +0000 (19:11 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 29 Mar 2007 19:11:22 +0000 (19:11 +0000)
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

lib/System/Unix/MappedFile.inc

index 4dccd138c1e95b1869b24be168ca997680c29bdb..5e76e2bc26aa24485f5bc03f4e09e1b4e83dd3b6 100644 (file)
@@ -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;
 }