[llvm-commits] CVS: llvm/lib/System/Unix/MappedFile.inc

Jeff Cohen jeffc at jolt-lang.org
Fri Mar 30 07:49:49 PDT 2007


Chris Lattner wrote:
>> 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.
>>     
>
> Interesting approach.  The problem is that fstat is significantly  
> faster than stat.  How about a new Path::getFileStatusFromFD()  
> method, which takes an open file descriptor.  If the System supports  
> it, it can get status information faster by using it, otherwise it  
> falls back to getFileStatus (e.g. if win32 doesn't have fstat)?
>
> -Chris
>   

It does, but names it _fstat.  I'm not sure it's worth the bother to 
cache fstat either.  stat is slow because it has to look up the file path.
>   
>> ---
>> Diffs of the changes:  (+3 -4)
>>
>>  MappedFile.inc |    7 +++----
>>  1 files changed, 3 insertions(+), 4 deletions(-)
>>
>>
>> Index: llvm/lib/System/Unix/MappedFile.inc
>> diff -u llvm/lib/System/Unix/MappedFile.inc:1.18 llvm/lib/System/ 
>> Unix/MappedFile.inc:1.19
>> --- llvm/lib/System/Unix/MappedFile.inc:1.18	Fri Aug 25 16:37:17 2006
>> +++ llvm/lib/System/Unix/MappedFile.inc	Thu Mar 29 14:11:22 2007
>> @@ -54,15 +54,14 @@
>>      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;
>>  }
>>
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>     
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
>   




More information about the llvm-commits mailing list