diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-03-01 11:47:00 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-03-01 11:47:00 +0000 |
commit | ee5e607355f76f0de64ea9ff5a380a5317627e05 (patch) | |
tree | 6282a5bbd14788534d8504dc154b12f953bc1589 /lib/Bitcode | |
parent | 73bbab9d755b7b196a0ba6a41caf9391a1d0abdf (diff) | |
download | llvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.gz llvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.bz2 llvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.xz |
Now that we have C++11, turn simple functors into lambdas and remove a ton of boilerplate.
No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index a1641043b2..9e7b12a93d 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -173,29 +173,19 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map, } } -// Optimize constant ordering. -namespace { - struct CstSortPredicate { - ValueEnumerator &VE; - explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {} - bool operator()(const std::pair<const Value*, unsigned> &LHS, - const std::pair<const Value*, unsigned> &RHS) { - // Sort by plane. - if (LHS.first->getType() != RHS.first->getType()) - return VE.getTypeID(LHS.first->getType()) < - VE.getTypeID(RHS.first->getType()); - // Then by frequency. - return LHS.second > RHS.second; - } - }; -} - /// OptimizeConstants - Reorder constant pool for denser encoding. void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) { if (CstStart == CstEnd || CstStart+1 == CstEnd) return; - CstSortPredicate P(*this); - std::stable_sort(Values.begin()+CstStart, Values.begin()+CstEnd, P); + std::stable_sort(Values.begin() + CstStart, Values.begin() + CstEnd, + [this](const std::pair<const Value *, unsigned> &LHS, + const std::pair<const Value *, unsigned> &RHS) { + // Sort by plane. + if (LHS.first->getType() != RHS.first->getType()) + return getTypeID(LHS.first->getType()) < getTypeID(RHS.first->getType()); + // Then by frequency. + return LHS.second > RHS.second; + }); // Ensure that integer and vector of integer constants are at the start of the // constant pool. This is important so that GEP structure indices come before |