[SIL] Avoid std::function in transform-iterators

In a non-rigorous test, this change shaves off 20% of the time spent
in SIL optimizations for the standard library in a +Asserts build.
(Admittedly the wins for a no-asserts build will be much lower because
SILInstructionResultArray has a bunch of assertions in its
constructor.)
This commit is contained in:
Jordan Rose
2018-05-04 17:30:10 -07:00
parent 2b31ba339f
commit 5bf9b9ac76
4 changed files with 42 additions and 35 deletions

View File

@@ -1354,7 +1354,7 @@ operator==(const SILInstructionResultArray &other) {
SILInstructionResultArray::type_range
SILInstructionResultArray::getTypes() const {
std::function<SILType(SILValue)> F = [](SILValue V) -> SILType {
SILType (*F)(SILValue) = [](SILValue V) -> SILType {
return V->getType();
};
return {llvm::map_iterator(begin(), F), llvm::map_iterator(end(), F)};