Bug 236784 - Use more StringView during CSP parsing
Summary: Use more StringView during CSP parsing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-17 08:16 PST by Chris Dumez
Modified: 2022-02-18 09:27 PST (History)
8 users (show)

See Also:


Attachments
Patch (7.04 KB, patch)
2022-02-17 08:18 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.00 KB, patch)
2022-02-17 19:51 PST, 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 2022-02-17 08:16:46 PST
Use more StringView during CSP parsing.
Comment 1 Chris Dumez 2022-02-17 08:18:30 PST
Created attachment 452372 [details]
Patch
Comment 2 Darin Adler 2022-02-17 16:20:24 PST
Comment on attachment 452372 [details]
Patch

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

As long as we don’t need these things to outlive the buffer we are parsing, this is a great thing to do.

> Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:386
> -template<typename CharacterType> std::optional<String> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> +template<typename CharacterType> std::optional<StringView> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)

Given that both String and StringView have a null value, I am surprised that we feel the need to use std::optional.
Comment 3 Chris Dumez 2022-02-17 16:22:08 PST
(In reply to Darin Adler from comment #2)
> Comment on attachment 452372 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=452372&action=review
> 
> As long as we don’t need these things to outlive the buffer we are parsing,
> this is a great thing to do.
> 
> > Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:386
> > -template<typename CharacterType> std::optional<String> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> > +template<typename CharacterType> std::optional<StringView> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> 
> Given that both String and StringView have a null value, I am surprised that
> we feel the need to use std::optional.

That is true. I'll see if I can fix this up too.
Comment 4 Chris Dumez 2022-02-17 19:51:28 PST
Created attachment 452473 [details]
Patch
Comment 5 EWS 2022-02-18 09:26:52 PST
Committed r290131 (247475@main): <https://commits.webkit.org/247475@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452473 [details].
Comment 6 Radar WebKit Bug Importer 2022-02-18 09:27:22 PST
<rdar://problem/89149597>