Changeset 248316 in webkit
- Timestamp:
- Aug 6, 2019, 2:45:32 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/URL.cpp (modified) (2 diffs)
-
Source/WTF/wtf/text/StringView.h (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/network/HTTPHeaderMap.cpp (modified) (2 diffs)
-
Source/WebCore/platform/network/HTTPHeaderMap.h (modified) (1 diff)
-
Source/WebCore/platform/network/HTTPParsers.cpp (modified) (1 diff)
-
Source/WebCore/testing/MockCDMFactory.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r248308 r248316 1 2019-08-06 Chris Dumez <cdumez@apple.com> 2 3 Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&) 4 https://bugs.webkit.org/show_bug.cgi?id=200475 5 6 Reviewed by Darin Adler. 7 8 Add convenience constuctor to StringView which takes in a const char* 9 and an unsigned length, similarly to what we already have for String. 10 11 * wtf/URL.cpp: 12 (WTF::URL::protocolIs const): 13 (WTF::protocolIsInternal): 14 * wtf/text/StringView.h: 15 (WTF::StringView::StringView): 16 (WTF::StringView::empty): 17 1 18 2019-08-06 Jiewen Tan <jiewen_tan@apple.com> 2 19 -
trunk/Source/WTF/wtf/URL.cpp
r243118 r248316 315 315 bool URL::protocolIs(const char* protocol) const 316 316 { 317 assertProtocolIsGood(StringView (reinterpret_cast<const LChar*>(protocol), strlen(protocol)));317 assertProtocolIsGood(StringView { protocol }); 318 318 319 319 // JavaScript URLs are "valid" and should be executed even if URL decides they are invalid. … … 771 771 { 772 772 // Do the comparison without making a new string object. 773 assertProtocolIsGood(StringView (reinterpret_cast<const LChar*>(protocol), strlen(protocol)));773 assertProtocolIsGood(StringView { protocol }); 774 774 bool isLeading = true; 775 775 for (unsigned i = 0, j = 0; url[i]; ++i) { -
trunk/Source/WTF/wtf/text/StringView.h
r246951 r248316 67 67 StringView(const UChar*, unsigned length); 68 68 StringView(const char*); 69 StringView(const char*, unsigned length); 69 70 70 71 static StringView empty(); … … 330 331 } 331 332 333 inline StringView::StringView(const char* characters, unsigned length) 334 { 335 initialize(reinterpret_cast<const LChar*>(characters), length); 336 } 337 332 338 inline StringView::StringView(const StringImpl& string) 333 339 { … … 379 385 inline StringView StringView::empty() 380 386 { 381 return StringView( reinterpret_cast<const LChar*>(""), 0);387 return StringView("", 0); 382 388 } 383 389 -
trunk/Source/WebCore/ChangeLog
r248310 r248316 1 2019-08-06 Chris Dumez <cdumez@apple.com> 2 3 Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&) 4 https://bugs.webkit.org/show_bug.cgi?id=200475 5 6 Reviewed by Darin Adler. 7 8 In the case where CFStringGetCStringPtr() succeeds in returning us a pointer 9 to the CFStringRef underlying characters but it is not a common header, we 10 would fall back to calling HTTPHeaderMap::set(const String&, const String&) 11 which would unecessarily call findHTTPHeaderName() again to try and determine 12 if it is a common header. Avoid this by introducing a new setUncommonHeader() 13 private method and calling this one instead. Also got rid of some code 14 duplication at the same time. 15 16 * platform/network/HTTPHeaderMap.cpp: 17 (WebCore::HTTPHeaderMap::set): 18 (WebCore::HTTPHeaderMap::setUncommonHeader): 19 * platform/network/HTTPHeaderMap.h: 20 * platform/network/HTTPParsers.cpp: 21 (WebCore::parseHTTPHeader): 22 * testing/MockCDMFactory.cpp: 23 (WebCore::MockCDMInstance::setServerCertificate): 24 1 25 2019-08-06 Saam Barati <sbarati@apple.com> 2 26 -
trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp
r232964 r248316 70 70 unsigned length = CFStringGetLength(name); 71 71 HTTPHeaderName headerName; 72 if (findHTTPHeaderName(StringView(reinterpret_cast<const LChar*>(nameCharacters), length), headerName)) { 73 auto index = m_commonHeaders.findMatching([&](auto& header) { 74 return header.key == headerName; 75 }); 76 if (index == notFound) 77 m_commonHeaders.append(CommonHeader { headerName, value }); 78 else 79 m_commonHeaders[index].value = value; 80 } else 81 set(String(nameCharacters, length), value); 72 if (findHTTPHeaderName(StringView(nameCharacters, length), headerName)) 73 set(headerName, value); 74 else 75 setUncommonHeader(String(nameCharacters, length), value); 76 82 77 return; 83 78 } … … 96 91 } 97 92 93 setUncommonHeader(name, value); 94 } 95 96 void HTTPHeaderMap::setUncommonHeader(const String& name, const String& value) 97 { 98 98 auto index = m_uncommonHeaders.findMatching([&](auto& header) { 99 99 return equalIgnoringASCIICase(header.key, name); -
trunk/Source/WebCore/platform/network/HTTPHeaderMap.h
r239427 r248316 203 203 204 204 private: 205 void setUncommonHeader(const String& name, const String& value); 206 205 207 CommonHeadersVector m_commonHeaders; 206 208 UncommonHeadersVector m_uncommonHeaders; -
trunk/Source/WebCore/platform/network/HTTPParsers.cpp
r246490 r248316 729 729 730 730 nameSize = name.size(); 731 nameStr = StringView( reinterpret_cast<const LChar*>(namePtr), nameSize);731 nameStr = StringView(namePtr, nameSize); 732 732 733 733 for (; p < end && *p == 0x20; p++) { } -
trunk/Source/WebCore/testing/MockCDMFactory.cpp
r246490 r248316 270 270 CDMInstance::SuccessValue MockCDMInstance::setServerCertificate(Ref<SharedBuffer>&& certificate) 271 271 { 272 StringView certificateStringView( reinterpret_cast<const LChar*>(certificate->data()), certificate->size());272 StringView certificateStringView(certificate->data(), certificate->size()); 273 273 274 274 if (equalIgnoringASCIICase(certificateStringView, "valid")) -
trunk/Tools/ChangeLog
r248315 r248316 1 2019-08-06 Chris Dumez <cdumez@apple.com> 2 3 Fix inefficiency in HTTPHeaderMap::set(CFStringRef, const String&) 4 https://bugs.webkit.org/show_bug.cgi?id=200475 5 6 Reviewed by Darin Adler. 7 8 * TestWebKitAPI/Tests/WTF/StringView.cpp: 9 (TestWebKitAPI::stringViewFromLiteral): 10 (TestWebKitAPI::stringViewFromUTF8): 11 1 12 2019-08-06 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
r234278 r248316 33 33 StringView stringViewFromLiteral(const char* characters) 34 34 { 35 return StringView( reinterpret_cast<const LChar*>(characters), strlen(characters));36 } 37 38 StringView stringViewFromUTF8(String &ref, const char* characters)35 return StringView(characters); 36 } 37 38 StringView stringViewFromUTF8(String& ref, const char* characters) 39 39 { 40 40 ref = String::fromUTF8(characters);
Note:
See TracChangeset
for help on using the changeset viewer.