[Cache API] Optimize whitespace trimming in Vary header values
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 18:46:17 +0000 (18:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 18:46:17 +0000 (18:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175837

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-22
Reviewed by Alex Christensen.

No change of behavior.

Introducing a StringView version of stripLeadingAndTrailingHTTPSpaces.

* Modules/cache/Cache.cpp:
(WebCore::hasResponseVaryStarHeaderValue):
* platform/network/HTTPParsers.h:
(WebCore::stripLeadingAndTrailingHTTPSpaces):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221031 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/Cache.cpp
Source/WebCore/platform/network/HTTPParsers.h

index 7245050..1c79eb7 100644 (file)
@@ -1,3 +1,19 @@
+2017-08-22  Youenn Fablet  <youenn@apple.com>
+
+        [Cache API] Optimize whitespace trimming in Vary header values
+        https://bugs.webkit.org/show_bug.cgi?id=175837
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        Introducing a StringView version of stripLeadingAndTrailingHTTPSpaces.
+
+        * Modules/cache/Cache.cpp:
+        (WebCore::hasResponseVaryStarHeaderValue):
+        * platform/network/HTTPParsers.h:
+        (WebCore::stripLeadingAndTrailingHTTPSpaces):
+
 2017-08-22  Alex Christensen  <achristensen@webkit.org>
 
         Remove ChromeClient::scrollbarsModeDidChange
index 3781d43..d642314 100644 (file)
@@ -127,7 +127,7 @@ static inline bool hasResponseVaryStarHeaderValue(const FetchResponse& response)
     auto varyValue = response.headers().internalHeaders().get(WebCore::HTTPHeaderName::Vary);
     bool hasStar = false;
     varyValue.split(',', false, [&](StringView view) {
-        if (!hasStar && stripLeadingAndTrailingHTTPSpaces(view.toStringWithoutCopying()) == "*")
+        if (!hasStar && stripLeadingAndTrailingHTTPSpaces(view) == "*")
             hasStar = true;
     });
     return hasStar;
index 4843677..685e83c 100644 (file)
@@ -112,6 +112,11 @@ inline String stripLeadingAndTrailingHTTPSpaces(const String& string)
     return string.stripWhiteSpace(isHTTPSpace);
 }
 
+inline StringView stripLeadingAndTrailingHTTPSpaces(StringView string)
+{
+    return string.stripLeadingAndTrailingMatchedCharacters(isHTTPSpace);
+}
+
 }
 
 #endif