From ea93fe00b9382fb8765b56688be47591492b637f Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 5 Apr 2017 00:43:25 +0000 Subject: [PATCH] Inline small functions that are used only once as lambdas. llvm-svn: 299494 --- lld/ELF/LinkerScript.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 16f75ea7749e..39e5a6d3b7dc 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -285,35 +285,31 @@ bool LinkerScript::shouldKeep(InputSectionBase *S) { return false; } -static bool comparePriority(InputSectionBase *A, InputSectionBase *B) { - return getPriority(A->Name) < getPriority(B->Name); -} - -static bool compareName(InputSectionBase *A, InputSectionBase *B) { - return A->Name < B->Name; -} - -static bool compareAlignment(InputSectionBase *A, InputSectionBase *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; -} - +// A helper function for the SORT() command. static std::function getComparator(SortSectionPolicy K) { switch (K) { case SortSectionPolicy::Alignment: - return compareAlignment; + return [](InputSectionBase *A, InputSectionBase *B) { + // ">" is not a mistake. Sections with larger alignments are placed + // before sections with smaller alignments in order to reduce the + // amount of padding necessary. This is compatible with GNU. + return A->Alignment > B->Alignment; + }; case SortSectionPolicy::Name: - return compareName; + return [](InputSectionBase *A, InputSectionBase *B) { + return A->Name < B->Name; + }; case SortSectionPolicy::Priority: - return comparePriority; + return [](InputSectionBase *A, InputSectionBase *B) { + return getPriority(A->Name) < getPriority(B->Name); + }; default: llvm_unreachable("unknown sort policy"); } } +// A helper function for the SORT() command. static bool matchConstraints(ArrayRef Sections, ConstraintKind Kind) { if (Kind == ConstraintKind::NoConstraint)