Convert a check to checkLazy.

This brings memory allocations when linking clang from 270.96MB to
267.80MB.

llvm-svn: 319932
This commit is contained in:
Rafael Espindola 2017-12-06 19:17:20 +00:00
parent 273d261b8f
commit b6e2ca4597
1 changed files with 3 additions and 2 deletions

View File

@ -279,8 +279,9 @@ template <class ELFT>
ArrayRef<typename ObjFile<ELFT>::Elf_Word>
ObjFile<ELFT>::getShtGroupEntries(const Elf_Shdr &Sec) {
const ELFFile<ELFT> &Obj = this->getObj();
ArrayRef<Elf_Word> Entries = check(
Obj.template getSectionContentsAsArray<Elf_Word>(&Sec), toString(this));
ArrayRef<Elf_Word> Entries =
checkLazy(Obj.template getSectionContentsAsArray<Elf_Word>(&Sec),
[=]() { return toString(this); });
if (Entries.empty() || Entries[0] != GRP_COMDAT)
fatal(toString(this) + ": unsupported SHT_GROUP format");
return Entries.slice(1);