Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&)
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2019 21:45:32 +0000 (21:45 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2019 21:45:32 +0000 (21:45 +0000)
commit5d8a6b760531e385e681ce924409e43d58b65bb1
tree77ae50f505d5d18f5be257af4e654eb19a3ec1ae
parentff6afe8264787fd683a2ed8721d1e4d11dd9209b
Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&)
https://bugs.webkit.org/show_bug.cgi?id=200475

Reviewed by Darin Adler.

Source/WebCore:

In the case where CFStringGetCStringPtr() succeeds in returning us a pointer
to the CFStringRef underlying characters but it is not a common header, we
would fall back to calling HTTPHeaderMap::set(const String&, const String&)
which would unecessarily call findHTTPHeaderName() again to try and determine
if it is a common header. Avoid this by introducing a new setUncommonHeader()
private method and calling this one instead. Also got rid of some code
duplication at the same time.

* platform/network/HTTPHeaderMap.cpp:
(WebCore::HTTPHeaderMap::set):
(WebCore::HTTPHeaderMap::setUncommonHeader):
* platform/network/HTTPHeaderMap.h:
* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPHeader):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDMInstance::setServerCertificate):

Source/WTF:

Add convenience constuctor to StringView which takes in a const char*
and an unsigned length, similarly to what we already have for String.

* wtf/URL.cpp:
(WTF::URL::protocolIs const):
(WTF::protocolIsInternal):
* wtf/text/StringView.h:
(WTF::StringView::StringView):
(WTF::StringView::empty):

Tools:

* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::stringViewFromLiteral):
(TestWebKitAPI::stringViewFromUTF8):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/URL.cpp
Source/WTF/wtf/text/StringView.h
Source/WebCore/ChangeLog
Source/WebCore/platform/network/HTTPHeaderMap.cpp
Source/WebCore/platform/network/HTTPHeaderMap.h
Source/WebCore/platform/network/HTTPParsers.cpp
Source/WebCore/testing/MockCDMFactory.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp