Bug 173519 - Use WTF::Function instead of std::function in WTF/
Summary: Use WTF::Function instead of std::function in WTF/
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-17 19:19 PDT by Chris Dumez
Modified: 2017-06-18 13:27 PDT (History)
6 users (show)

See Also:


Attachments
Patch (17.68 KB, patch)
2017-06-17 21:34 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-06-17 19:19:24 PDT
Use WTF::Function instead of std::function in WTF/ to avoid copying.
Comment 1 Chris Dumez 2017-06-17 21:34:48 PDT
Created attachment 313219 [details]
Patch
Comment 2 Build Bot 2017-06-17 21:35:51 PDT
Attachment 313219 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/MemoryPressureHandler.h:175:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WTF/wtf/MemoryPressureHandler.h:182:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WTF/wtf/RefCounter.h:62:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp:102:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 4 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Sam Weinig 2017-06-18 11:36:41 PDT
Comment on attachment 313219 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=313219&action=review

> Source/WTF/wtf/text/WTFString.h:370
> +    using SplitFunctor = WTF::Function<void(const StringView&)>;
> +    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;

This kind of basic algorithm seems like it should a template function and take the functor as a template parameter.
Comment 4 Chris Dumez 2017-06-18 11:37:25 PDT
(In reply to Sam Weinig from comment #3)
> Comment on attachment 313219 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=313219&action=review
> 
> > Source/WTF/wtf/text/WTFString.h:370
> > +    using SplitFunctor = WTF::Function<void(const StringView&)>;
> > +    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;
> 
> This kind of basic algorithm seems like it should a template function and
> take the functor as a template parameter.

Agreed. Should I do it in this patch or a follow-up?
Comment 5 Chris Dumez 2017-06-18 12:19:52 PDT
Comment on attachment 313219 [details]
Patch

Will do in a follow-up.
Comment 6 WebKit Commit Bot 2017-06-18 12:49:16 PDT
Comment on attachment 313219 [details]
Patch

Clearing flags on attachment: 313219

Committed r218464: <http://trac.webkit.org/changeset/218464>
Comment 7 WebKit Commit Bot 2017-06-18 12:49:17 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Sam Weinig 2017-06-18 13:20:10 PDT
(In reply to Chris Dumez from comment #4)
> (In reply to Sam Weinig from comment #3)
> > Comment on attachment 313219 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=313219&action=review
> > 
> > > Source/WTF/wtf/text/WTFString.h:370
> > > +    using SplitFunctor = WTF::Function<void(const StringView&)>;
> > > +    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;
> > 
> > This kind of basic algorithm seems like it should a template function and
> > take the functor as a template parameter.
> 
> Agreed. Should I do it in this patch or a follow-up?

Follow-up probably.
Comment 9 Chris Dumez 2017-06-18 13:27:16 PDT
Comment on attachment 313219 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=313219&action=review

>>>> Source/WTF/wtf/text/WTFString.h:370
>>>> +    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;
>>> 
>>> This kind of basic algorithm seems like it should a template function and take the functor as a template parameter.
>> 
>> Agreed. Should I do it in this patch or a follow-up?
> 
> Follow-up probably.

Note that in this case though, it would force us to move the implementation in the header (it is currently in the cpp).