Reduce size of WebCore::URL
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 00:28:36 +0000 (00:28 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 00:28:36 +0000 (00:28 +0000)
commit75a3c99e226bd7b341b094850d842393824f942e
tree18f5131a620743b6fe284ba5c60b14ef41efa5f0
parentbff58a23ed3d8ae18c19ddad540db310387981fe
Reduce size of WebCore::URL
https://bugs.webkit.org/show_bug.cgi?id=186820

Reviewed by Yusuke Suzuki and Youenn Fablet.

Source/WebCore:

We were using 32 bits for the length of the port, which is always between 0 and 5 inclusive
because port numbers are missing or between 0 and 65535.  Let's just use 3 bits here.
We were using 32 bits for the length of the scheme, which is usually 3-5 characters and can be
longer for some custom schemes, but I've never seen one more than 20 characters.  If we assume
schemes are always less than 64MB, we can save 8 bytes per URL!

No change in behavior, just less memory use!

To restore the IPC encoding to how it was before r221165, I just encode the string and reparse it.

* platform/URL.cpp:
(WebCore::URL::invalidate):
(WebCore::URL::lastPathComponent const):
(WebCore::URL::port const):
(WebCore::URL::protocolHostAndPort const):
(WebCore::URL::path const):
(WebCore::URL::removePort):
(WebCore::URL::setPort):
(WebCore::URL::setHostAndPort):
(WebCore::URL::setPath):
* platform/URL.h:
(WebCore::URL::encode const):
(WebCore::URL::decode):
(WebCore::URL::hasPath const):
(WebCore::URL::pathStart const):
* platform/URLParser.cpp:
(WebCore::URLParser::copyBaseWindowsDriveLetter):
(WebCore::URLParser::urlLengthUntilPart):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::shouldPopPath):
(WebCore::URLParser::popPath):
(WebCore::URLParser::parse):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
* workers/service/server/RegistrationDatabase.cpp:
Increment the service worker registration schema version because of the URL encoding change.

Source/WebKit:

* NetworkProcess/cache/NetworkCacheStorage.h:
Increment cache version because of URL encoding change.

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/URL.h
Source/WebCore/platform/URLParser.cpp
Source/WebCore/workers/service/server/RegistrationDatabase.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp