Changes in directory llvm/lib/System/Unix:
MappedFile.inc updated: 1.12 -> 1.13 --- Log message: Reduce code in the error path by only allocating info_ if everything looks good. --- Diffs of the changes: (+8 -10) MappedFile.inc | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) Index: llvm/lib/System/Unix/MappedFile.inc diff -u llvm/lib/System/Unix/MappedFile.inc:1.12 llvm/lib/System/Unix/MappedFile.inc:1.13 --- llvm/lib/System/Unix/MappedFile.inc:1.12 Tue Jul 18 01:52:52 2006 +++ llvm/lib/System/Unix/MappedFile.inc Tue Jul 18 01:57:51 2006 @@ -43,7 +43,6 @@ if (!path_.exists()) throw std::string("Can't open file: ") + path_.toString(); - info_ = new MappedFileInfo; int mode = 0; if (options_&READ_ACCESS) if (options_&WRITE_ACCESS) @@ -52,20 +51,19 @@ mode = O_RDONLY; else if (options_&WRITE_ACCESS) mode = O_WRONLY; - info_->fd_ = ::open(path_.c_str(),mode); - if (info_->fd_ < 0) { - delete info_; - info_ = 0; + int FD = ::open(path_.c_str(), mode); + if (FD < 0) ThrowErrno(std::string("Can't open file: ") + path_.toString()); - } + struct stat sbuf; - if(::fstat(info_->fd_, &info_->sbuf_) < 0) { - ::close(info_->fd_); - delete info_; - info_ = 0; + if(::fstat(FD, &sbuf) < 0) { + ::close(FD); ThrowErrno(std::string("Can't stat file: ") + path_.toString()); } + info_ = new MappedFileInfo; + info_->fd_ = FD; + info_->sbuf_ = sbuf; } void MappedFile::terminate() { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits