ELF: Avoid string concatenation if there's no error.
llvm-svn: 255870
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 175ccd3..9af7fd8 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -318,10 +318,11 @@
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 @@
"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;