This is an archive of the discontinued LLVM Phabricator instance.

[Common] Threads: use function_ref instead of std::function
ClosedPublic

Authored by MaskRay on Nov 21 2018, 2:07 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Nov 21 2018, 2:07 PM
ruiu added a comment.Nov 26 2018, 11:23 AM

What is a benefit of doing this?

What is a benefit of doing this?

a) Performance (very minor): it removes a heap allocation of the 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 (at least 17 times).

ruiu accepted this revision.Nov 26 2018, 4:23 PM

LGTM

This revision is now accepted and ready to land.Nov 26 2018, 4:23 PM
This revision was automatically updated to reflect the committed changes.