WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
230058
Use std::not_fn instead of lambda in URLParser
https://bugs.webkit.org/show_bug.cgi?id=230058
Summary
Use std::not_fn instead of lambda in URLParser
Alex Christensen
Reported
2021-09-08 12:35:20 PDT
Use std::not_fn instead of lambda in URLParser
Attachments
Patch
(7.17 KB, patch)
2021-09-08 12:48 PDT
,
Alex Christensen
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(9.51 KB, patch)
2021-09-08 13:24 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(9.66 KB, patch)
2021-09-08 16:35 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(12.72 KB, patch)
2021-09-09 20:49 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(9.35 KB, patch)
2021-09-10 00:21 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(9.51 KB, patch)
2021-09-10 09:03 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(10.65 KB, patch)
2021-09-10 15:37 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(6)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2021-09-08 12:48:13 PDT
Created
attachment 437657
[details]
Patch
Alex Christensen
Comment 2
2021-09-08 13:24:40 PDT
Created
attachment 437662
[details]
Patch
Alex Christensen
Comment 3
2021-09-08 16:35:41 PDT
Created
attachment 437678
[details]
Patch
Fujii Hironori
Comment 4
2021-09-09 16:58:06 PDT
Comment on
attachment 437678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437678&action=review
> Source/WTF/wtf/text/StringCommon.h:539 > +template<typename CharacterType, std::enable_if_t<std::is_integral<CharacterType>::value>* = nullptr>
You can use std::is_integral_v.
> Source/WTF/wtf/text/StringImpl.h:596 > +template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r<bool, CodeUnitMatchFunction, UChar>::value>* = nullptr>
UChar → LChar You can use is_invocable_r_v.
Alex Christensen
Comment 5
2021-09-09 20:47:38 PDT
Comment on
attachment 437678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437678&action=review
>> Source/WTF/wtf/text/StringImpl.h:596 >> +template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r<bool, CodeUnitMatchFunction, UChar>::value>* = nullptr> > > UChar → LChar > You can use is_invocable_r_v.
UChar is correct here because CodeUnitMatchFunction used to be bool (*)(UChar) and it will be called with UChar. I like is_invocable_r_v though.
Alex Christensen
Comment 6
2021-09-09 20:49:41 PDT
Created
attachment 437831
[details]
Patch
Fujii Hironori
Comment 7
2021-09-09 20:55:17 PDT
Comment on
attachment 437831
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437831&action=review
> Source/WTF/wtf/text/WTFString.h:173 > size_t find(CodeUnitMatchFunction matchFunction, unsigned start = 0) const { return m_impl ? m_impl->find(matchFunction, start) : notFound; }
Does this copy the matchFunction object? Should you use CodeUnitMatchFunction&& and std::forward here? You don't templatize StringImpl::find(CodeUnitMatchFunction, unsigned index). Why can you call it with matchFunction? Does this convert matchFunction to bool (*)(UChar)? If so, why do you need to templatize this method?
Fujii Hironori
Comment 8
2021-09-09 21:07:35 PDT
Comment on
attachment 437831
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437831&action=review
> Source/WTF/wtf/text/StringImpl.h:659 > +template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>*>
Now both 'find' are template functions. How about unifying them by templatize LChar and UChar?
Fujii Hironori
Comment 9
2021-09-09 21:14:47 PDT
Comment on
attachment 437831
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437831&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:78 > +static TestNavigationDelegate *delegateAllowingAllTLS()
These changes seems came from other bug.
Alex Christensen
Comment 10
2021-09-10 00:09:15 PDT
Oh I see. LChar is indeed correct in the one you suggested because it will be called with LChar.
Alex Christensen
Comment 11
2021-09-10 00:21:55 PDT
Created
attachment 437848
[details]
Patch
Fujii Hironori
Comment 12
2021-09-10 00:44:04 PDT
Comment on
attachment 437848
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437848&action=review
> Source/WebCore/ChangeLog:8 > + Add a few explicit template parameters needed since we are passing a template parameter now instead of a function pointer.
You don't modify String::find in this patch. You don't need this change.
> Source/WTF/wtf/text/StringImpl.h:647 > +inline size_t find(const CodeUnit* characters, unsigned length, CodeUnitMatchFunction matchFunction, unsigned index)
I think it should be CodeUnitMatchFunction&&. Otherwide the callable object is coped.
Fujii Hironori
Comment 13
2021-09-10 05:15:30 PDT
Comment on
attachment 437848
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437848&action=review
>> Source/WTF/wtf/text/StringImpl.h:647 >> +inline size_t find(const CodeUnit* characters, unsigned length, CodeUnitMatchFunction matchFunction, unsigned index) > > I think it should be CodeUnitMatchFunction&&. Otherwide the callable object is coped.
It's so-called Universal Reference.
Alex Christensen
Comment 14
2021-09-10 09:03:42 PDT
Created
attachment 437877
[details]
Patch
Fujii Hironori
Comment 15
2021-09-10 14:24:21 PDT
Comment on
attachment 437877
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437877&action=review
> Source/WTF/wtf/text/StringImpl.h:647 > +inline size_t find(const CodeUnit* characters, unsigned length, CodeUnitMatchFunction&& matchFunction, unsigned index)
'find' functions in StringCommon.h and StringImpl.h are similar. I think they should be in the same file.
> Source/WebCore/html/DOMTokenList.cpp:47 > + return token.find(isHTMLSpace<UChar>) != notFound;
You don't modify String::find in this patch. Why do you need this change?
Alex Christensen
Comment 16
2021-09-10 14:25:33 PDT
It used to be able to infer <UChar> because it was being passed as a bool(*)(UChar) but now it can't because it's a templatized invocable.
Fujii Hironori
Comment 17
2021-09-10 15:13:32 PDT
Comment on
attachment 437877
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437877&action=review
>> Source/WebCore/html/DOMTokenList.cpp:47 >> + return token.find(isHTMLSpace<UChar>) != notFound; > > You don't modify String::find in this patch. Why do you need this change?
I confirmed that this patch can compile without this change.
Darin Adler
Comment 18
2021-09-10 15:28:23 PDT
Comment on
attachment 437877
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=437877&action=review
> Source/WTF/wtf/URLParser.cpp:2710 > + return segment.find(std::not_fn(isASCIIHexDigit<UChar>), 2) == notFound;
find == notFound is harder to read than !contains; can we add/use contains instead?
Alex Christensen
Comment 19
2021-09-10 15:37:07 PDT
Created
attachment 437916
[details]
Patch
EWS
Comment 20
2021-09-10 16:51:54 PDT
Committed
r282303
(
241575@main
): <
https://commits.webkit.org/241575@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 437916
[details]
.
Radar WebKit Bug Importer
Comment 21
2021-09-10 16:52:27 PDT
<
rdar://problem/82995709
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug