Using WTF::Function (or std::function) in cases where are using a functor as an abstraction to allow scope customization, iteration or predicate functions is wasteful. We should instead be using the non-allocating WTF::ScopedLambda. Some examples in WebCore are: - the traverseSubresources() functions on various classes. - readURLsFromPasteboardAsString() in DataTransfer.cpp - Document::forEachMediaElement() - etc.
Grep for "const Function&" perhaps to find a lot of these?
Is there a reason this class needs to be named "lambda" and not "function"?
(In reply to Darin Adler from comment #2) > Is there a reason this class needs to be named "lambda" and not "function"? The patch that added it doesn't give much justification: https://trac.webkit.org/changeset/191705/webkit Phil, any reason you chose "lambda" over "function" here?
<rdar://problem/78407384>