summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-04-03 20:08:45 +0000
committerRui Ueyama <ruiu@google.com>2018-04-03 20:08:45 +0000
commitc6bf37d56d73d8ab1c1da86ce4cfd21afb0ab43a (patch)
treeb27c1e0a5badeffff558f7f9e79785708d8dd43e
parentbca630bd611de57c113b805627a40fb0066a4ed3 (diff)
downloadbcm5719-llvm-c6bf37d56d73d8ab1c1da86ce4cfd21afb0ab43a.tar.gz
bcm5719-llvm-c6bf37d56d73d8ab1c1da86ce4cfd21afb0ab43a.zip
Instead of using std::copy, clear the vector first and add new elements. NFC.
Differential Revision: https://reviews.llvm.org/D45227 llvm-svn: 329107
-rw-r--r--lld/ELF/Writer.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 610e2656e7a..68dda6f06cf 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1137,24 +1137,23 @@ sortISDBySectionOrder(InputSectionDescription *ISD,
// of the second block of cold code can call the hot code without a thunk. So
// we effectively double the amount of code that could potentially call into
// the hot code without a thunk.
- size_t UnorderedInsPt = 0;
+ size_t InsPt = 0;
if (Target->ThunkSectionSpacing && !OrderedSections.empty()) {
uint64_t UnorderedPos = 0;
- for (; UnorderedInsPt != UnorderedSections.size(); ++UnorderedInsPt) {
- UnorderedPos += UnorderedSections[UnorderedInsPt]->getSize();
+ for (; InsPt != UnorderedSections.size(); ++InsPt) {
+ UnorderedPos += UnorderedSections[InsPt]->getSize();
if (UnorderedPos > UnorderedSize / 2)
break;
}
}
- std::copy(UnorderedSections.begin(),
- UnorderedSections.begin() + UnorderedInsPt, ISD->Sections.begin());
- std::vector<InputSection *>::iterator SectionsPos =
- ISD->Sections.begin() + UnorderedInsPt;
+ ISD->Sections.clear();
+ for (InputSection *IS : makeArrayRef(UnorderedSections).slice(0, InsPt))
+ ISD->Sections.push_back(IS);
for (std::pair<InputSection *, int> P : OrderedSections)
- *SectionsPos++ = P.first;
- std::copy(UnorderedSections.begin() + UnorderedInsPt, UnorderedSections.end(),
- SectionsPos);
+ ISD->Sections.push_back(P.first);
+ for (InputSection *IS : makeArrayRef(UnorderedSections).slice(InsPt))
+ ISD->Sections.push_back(IS);
}
static void sortSection(OutputSection *Sec,
OpenPOWER on IntegriCloud