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
This commit is contained in:
Benjamin Kramer
2014-03-01 11:47:00 +00:00
parent 73bbab9d75
commit ee5e607355
20 changed files with 114 additions and 312 deletions

View File

@ -409,23 +409,6 @@ MachineBasicBlock *MachineBlockPlacement::selectBestSuccessor(
return BestSucc;
}
namespace {
/// \brief Predicate struct to detect blocks already placed.
class IsBlockPlaced {
const BlockChain &PlacedChain;
const BlockToChainMapType &BlockToChain;
public:
IsBlockPlaced(const BlockChain &PlacedChain,
const BlockToChainMapType &BlockToChain)
: PlacedChain(PlacedChain), BlockToChain(BlockToChain) {}
bool operator()(MachineBasicBlock *BB) const {
return BlockToChain.lookup(BB) == &PlacedChain;
}
};
}
/// \brief Select the best block from a worklist.
///
/// This looks through the provided worklist as a list of candidate basic
@ -444,7 +427,9 @@ MachineBasicBlock *MachineBlockPlacement::selectBestCandidateBlock(
// FIXME: If this shows up on profiles, it could be folded (at the cost of
// some code complexity) into the loop below.
WorkList.erase(std::remove_if(WorkList.begin(), WorkList.end(),
IsBlockPlaced(Chain, BlockToChain)),
[&](MachineBasicBlock *BB) {
return BlockToChain.lookup(BB) == &Chain;
}),
WorkList.end());
MachineBasicBlock *BestBlock = 0;