ELF: Avoid string concatenation if there's no error.

llvm-svn: 255870
This commit is contained in:
Rui Ueyama 2015-12-17 01:51:23 +00:00
parent 05ac43fec3
commit 784b769d32
1 changed files with 8 additions and 6 deletions

View File

@ -318,10 +318,11 @@ MemoryBufferRef ArchiveFile::getMember(const Archive::Symbol *Sym) {
if (!Seen.insert(C.getChildOffset()).second)
return MemoryBufferRef();
ErrorOr<MemoryBufferRef> Ret = C.getMemoryBufferRef();
error(Ret, "Could not get the buffer for the member defining symbol " +
Sym->getName());
return *Ret;
ErrorOr<MemoryBufferRef> RefOrErr = C.getMemoryBufferRef();
if (!RefOrErr)
error(RefOrErr, "Could not get the buffer for the member defining symbol " +
Sym->getName());
return *RefOrErr;
}
std::vector<MemoryBufferRef> ArchiveFile::getMembers() {
@ -333,8 +334,9 @@ std::vector<MemoryBufferRef> ArchiveFile::getMembers() {
"Could not get the child of the archive " + File->getFileName());
const Archive::Child Child(*ChildOrErr);
ErrorOr<MemoryBufferRef> MbOrErr = Child.getMemoryBufferRef();
error(MbOrErr, "Could not get the buffer for a child of the archive " +
File->getFileName());
if (!MbOrErr)
error(MbOrErr, "Could not get the buffer for a child of the archive " +
File->getFileName());
Result.push_back(MbOrErr.get());
}
return Result;