[Common] Threads: use function_ref instead of std::function
The benefits are: a) Performance (very minor): it removes a heap allocation of the std::function constructor (template<class F> function(F f)) b) Clarity: it suggests that the callable's lifetime should end after the callee returns. Such callback is widely used in llvm. lld also uses it a lot. Reviewers: ruiu, rnk, pcc Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54813 llvm-svn: 347620
This commit is contained in:
parent
3bd249018c
commit
41828e7e52
|
@ -74,7 +74,7 @@ template <typename R, class FuncTy> void parallelForEach(R &&Range, FuncTy Fn) {
|
|||
}
|
||||
|
||||
inline void parallelForEachN(size_t Begin, size_t End,
|
||||
std::function<void(size_t)> Fn) {
|
||||
llvm::function_ref<void(size_t)> Fn) {
|
||||
if (ThreadsEnabled)
|
||||
for_each_n(llvm::parallel::par, Begin, End, Fn);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue