Bug 200475 - Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&)
Summary: Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-08-06 11:54 PDT by Chris Dumez
Modified: 2019-08-06 14:46 PDT (History)
12 users (show)

See Also:


Attachments
Patch (3.69 KB, patch)
2019-08-06 11:57 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.72 KB, patch)
2019-08-06 12:30 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 2019-08-06 11:54:43 PDT
Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&).
Comment 1 Chris Dumez 2019-08-06 11:57:32 PDT
Created attachment 375639 [details]
Patch
Comment 2 Darin Adler 2019-08-06 12:00:39 PDT
Comment on attachment 375639 [details]
Patch

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

> Source/WebCore/platform/network/HTTPHeaderMap.cpp:75
> +        if (findHTTPHeaderName(StringView(reinterpret_cast<const LChar*>(nameCharacters), length), headerName))
> +            set(headerName, value);
> +        else
> +            setUncommonHeader(String(nameCharacters, length), value);

Strikes me as strange that StringView requires the cast to LChar* and String does not.
Comment 3 Chris Dumez 2019-08-06 12:02:24 PDT
(In reply to Darin Adler from comment #2)
> Comment on attachment 375639 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=375639&action=review
> 
> > Source/WebCore/platform/network/HTTPHeaderMap.cpp:75
> > +        if (findHTTPHeaderName(StringView(reinterpret_cast<const LChar*>(nameCharacters), length), headerName))
> > +            set(headerName, value);
> > +        else
> > +            setUncommonHeader(String(nameCharacters, length), value);
> 
> Strikes me as strange that StringView requires the cast to LChar* and String
> does not.

    StringView(const LChar*, unsigned length);
    StringView(const UChar*, unsigned length);
    StringView(const char*);

We're missing:
    StringView(const char*, unsigned length);

Should I add it?
Comment 4 Darin Adler 2019-08-06 12:09:08 PDT
(In reply to Chris Dumez from comment #3)
>     StringView(const LChar*, unsigned length);
>     StringView(const UChar*, unsigned length);
>     StringView(const char*);
> 
> We're missing:
>     StringView(const char*, unsigned length);
> 
> Should I add it?

Yes.

If we already have the one without a length, then yes I think you should add it. The counter argument is that if we have a "const char*" with UTF-8 in it, we don’t want someone to accidentally interpret it as Latin-1. But I’m not sure that leaving this one particular overload out of StringView helps much with that problem.
Comment 5 Chris Dumez 2019-08-06 12:30:00 PDT
Created attachment 375643 [details]
Patch
Comment 6 WebKit Commit Bot 2019-08-06 14:45:39 PDT
Comment on attachment 375643 [details]
Patch

Clearing flags on attachment: 375643

Committed r248316: <https://trac.webkit.org/changeset/248316>
Comment 7 WebKit Commit Bot 2019-08-06 14:45:41 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2019-08-06 14:46:24 PDT
<rdar://problem/54004727>