From c0028d3d3b9bf9e09137480aca48f684093ca544 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 8 Sep 2016 20:47:52 +0000 Subject: [PATCH] Reduce templating. NFC. llvm-svn: 280986 --- lld/ELF/LinkerScript.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 7af2a1a..eeb6dc2 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -130,26 +130,22 @@ LinkerScript::getInputSections(const InputSectionDescription *I) { return Ret; } -template -static bool compareName(InputSectionBase *A, InputSectionBase *B) { +static bool compareName(InputSectionData *A, InputSectionData *B) { return A->Name < B->Name; } -template -static bool compareAlignment(InputSectionBase *A, - InputSectionBase *B) { +static bool compareAlignment(InputSectionData *A, InputSectionData *B) { // ">" is not a mistake. Larger alignments are placed before smaller // alignments in order to reduce the amount of padding necessary. // This is compatible with GNU. return A->Alignment > B->Alignment; } -template -static std::function *, InputSectionBase *)> +static std::function getComparator(SortKind K) { if (K == SortByName) - return compareName; - return compareAlignment; + return compareName; + return compareAlignment; } template @@ -200,9 +196,9 @@ LinkerScript::createInputSectionList(OutputSectionCommand &OutCmd) { if (!matchConstraints(V, OutCmd.Constraint)) continue; if (Cmd->SortInner) - std::stable_sort(V.begin(), V.end(), getComparator(Cmd->SortInner)); + std::stable_sort(V.begin(), V.end(), getComparator(Cmd->SortInner)); if (Cmd->SortOuter) - std::stable_sort(V.begin(), V.end(), getComparator(Cmd->SortOuter)); + std::stable_sort(V.begin(), V.end(), getComparator(Cmd->SortOuter)); // Add all input sections corresponding to rule 'Cmd' to // resulting vector. We do not add duplicate input sections. -- 2.7.4