Optimize parseCacheHeader() by using StringView
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jun 2016 00:25:44 +0000 (00:25 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jun 2016 00:25:44 +0000 (00:25 +0000)
commit30b2ab40156b212d553a167d5bfce38be8b856a4
tree6bcf2c84cf3c7e615bb74d31f4acea092d780985
parentd46c1b9f1a9cafe32154ec97cddc18574b634a25
Optimize parseCacheHeader() by using StringView
https://bugs.webkit.org/show_bug.cgi?id=158891

Reviewed by Darin Adler.

Source/WebCore:

Optimize parseCacheHeader() and avoid some temporary String allocations
by using StringView. We now strip the whitespaces in the input string
at the beginning of the function, at the same as as we strip the
control characters. We are then able to leverage StringView in the
rest of the function to get substrings without the need for extra
String allocations.

* platform/network/CacheValidation.cpp:
(WebCore::isControlCharacterOrSpace):
(WebCore::trimToNextSeparator):
(WebCore::parseCacheHeader):

Source/WTF:

Add a StringView::find() overload which takes a CharacterMatchFunction
to match the one on String.

* wtf/text/StringView.h:
(WTF::StringView::find):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringView.h
Source/WebCore/ChangeLog
Source/WebCore/platform/network/CacheValidation.cpp