diff options
| author | Davide Italiano <davide@freebsd.org> | 2016-11-18 02:18:04 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2016-11-18 02:18:04 +0000 |
| commit | 44665e7bc521c946b2c33388485fdd545ccdf9f2 (patch) | |
| tree | f154b0beab16130f74d8a9bdbfdcfadcfd944260 | |
| parent | 53088dd44dc5756c992dbb7e461ee6f4f7b7f02d (diff) | |
| download | bcm5719-llvm-44665e7bc521c946b2c33388485fdd545ccdf9f2.tar.gz bcm5719-llvm-44665e7bc521c946b2c33388485fdd545ccdf9f2.zip | |
[ELF] Use std::for_each() and hoist common code in a lambda.
llvm-svn: 287296
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 4bf95294a04..6034db13d5d 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -542,13 +542,11 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) { ArrayRef<uint8_t> Filler = Script<ELFT>::X->getFiller(this->Name); if (!Filler.empty()) fill(Buf, this->Size, Filler); - if (Config->Threads) { - parallel_for_each(Sections.begin(), Sections.end(), - [=](InputSection<ELFT> *C) { C->writeTo(Buf); }); - } else { - for (InputSection<ELFT> *C : Sections) - C->writeTo(Buf); - } + auto Fn = [=](InputSection<ELFT> *C) { C->writeTo(Buf); }; + if (Config->Threads) + parallel_for_each(Sections.begin(), Sections.end(), Fn); + else + std::for_each(Sections.begin(), Sections.end(), Fn); // Linker scripts may have BYTE()-family commands with which you // can write arbitrary bytes to the output. Process them if any. Script<ELFT>::X->writeDataBytes(this->Name, Buf); |

