From 87f2f9b4656fb11104bbb2d80fcfaac998865f50 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Thu, 21 Jan 2010 03:43:13 +0000 Subject: [PATCH] Avoid instantiating std::sort to save on compiler size. llvm-svn: 94065 --- clang/lib/Sema/SemaDecl.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1f7ef3d23e6e..17a2c8089f6f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1411,16 +1411,10 @@ static SourceLocation MarkLiveTop(CFGBlock *e, llvm::BitVector &live, return top; } -namespace { -class LineCmp { - SourceManager &SM; -public: - LineCmp(SourceManager &sm) : SM(sm) { - } - bool operator () (SourceLocation l1, SourceLocation l2) { - return l1 < l2; - } -}; +static int LineCmp(const void *p1, const void *p2) { + SourceLocation *Line1 = (SourceLocation *)p1; + SourceLocation *Line2 = (SourceLocation *)p2; + return !(*Line1 < *Line2); } /// CheckUnreachable - Check for unreachable code. @@ -1477,7 +1471,7 @@ void Sema::CheckUnreachable(AnalysisContext &AC) { } } - std::sort(lines.begin(), lines.end(), LineCmp(Context.getSourceManager())); + llvm::array_pod_sort(lines.begin(), lines.end(), LineCmp); for (llvm::SmallVector::iterator I = lines.begin(), E = lines.end(); I != E; -- GitLab