Create only one vector instead of two.

In this for-loop, we append elements from one vector to another,
which is a bit inefficient.

llvm-svn: 277653
This commit is contained in:
Rui Ueyama 2016-08-03 21:12:09 +00:00
parent 363da6f589
commit e7f912cd8f
1 changed files with 10 additions and 8 deletions

View File

@ -160,20 +160,22 @@ void LinkerScript<ELFT>::createSections(
OutputSections = Out;
for (auto &P : getSectionMap()) {
std::vector<InputSectionBase<ELFT> *> Sections;
StringRef OutputName = P.first;
const InputSectionDescription *I = P.second;
for (InputSectionBase<ELFT> *S : getInputSections(I)) {
if (OutputName == "/DISCARD/") {
const InputSectionDescription *Cmd = P.second;
std::vector<InputSectionBase<ELFT> *> Sections = getInputSections(Cmd);
if (OutputName == "/DISCARD/") {
for (InputSectionBase<ELFT> *S : Sections) {
S->Live = false;
reportDiscarded(S);
continue;
}
Sections.push_back(S);
continue;
}
if (I->Sort != SortKind::None)
if (Cmd->Sort != SortKind::None)
std::stable_sort(Sections.begin(), Sections.end(),
SectionsSorter<ELFT>(I->Sort));
SectionsSorter<ELFT>(Cmd->Sort));
for (InputSectionBase<ELFT> *S : Sections)
addSection(Factory, *Out, S, OutputName);
}