WebKit Bugzilla
Attachment 372783 Details for
Bug 187460
: ResourceResponseBase wastes a lot of space because of std::optional<>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187460-20190624211241.patch (text/plain), 9.75 KB, created by
Rob Buis
on 2019-06-24 12:12:42 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2019-06-24 12:12:42 PDT
Size:
9.75 KB
patch
obsolete
>Subversion Revision: 246743 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9d44f8e3995e16229fb3612f743fbe29129765b1..4d006aec17f4347ec5d48f4d19d5cd6f2e509733 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2019-06-24 Rob Buis <rbuis@igalia.com> >+ >+ ResourceResponseBase wastes a lot of space because of std::optional<> >+ https://bugs.webkit.org/show_bug.cgi?id=187460 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Waste less space in ResourceResponseBase by shrinking >+ ParsedContentRange. >+ >+ No new tests because there is no behavior change. >+ >+ * platform/network/NetworkLoadMetrics.h: >+ * platform/network/ParsedContentRange.cpp: >+ (WebCore::areContentRangeValuesValid): >+ (WebCore::parseContentRange): >+ (WebCore::ParsedContentRange::ParsedContentRange): >+ (WebCore::ParsedContentRange::headerValue const): >+ * platform/network/ParsedContentRange.h: >+ (WebCore::ParsedContentRange::isValid const): >+ (WebCore::ParsedContentRange::lastBytePosition const): >+ * platform/network/ResourceResponseBase.cpp: >+ (WebCore::ResourceResponseBase::isSuccessful const): >+ (WebCore::ResourceResponseBase::httpStatusCode const): >+ (WebCore::ResourceResponseBase::setHTTPStatusCode): >+ * platform/network/ResourceResponseBase.h: >+ (WebCore::ResourceResponseBase::isRedirectionStatusCode): >+ > 2019-06-24 Greg Doolittle <gr3g@apple.com> > > Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements with existing alt attr, but no value: <img alt> >diff --git a/Source/WebCore/platform/network/NetworkLoadMetrics.h b/Source/WebCore/platform/network/NetworkLoadMetrics.h >index 03c18b6927a2d4060e98f4d23f1db52841d275ae..b1170837f9cbb687ed696fd466cdc54e81ec2f60 100644 >--- a/Source/WebCore/platform/network/NetworkLoadMetrics.h >+++ b/Source/WebCore/platform/network/NetworkLoadMetrics.h >@@ -168,12 +168,12 @@ public: > String connectionIdentifier; > NetworkLoadPriority priority; > >- String tlsProtocol; >- String tlsCipher; >- > // Whether or not all of the properties (0 or otherwise) have been set. > bool complete { false }; > >+ String tlsProtocol; >+ String tlsCipher; >+ > HTTPHeaderMap requestHeaders; > > uint64_t requestHeaderBytesSent; >diff --git a/Source/WebCore/platform/network/ParsedContentRange.cpp b/Source/WebCore/platform/network/ParsedContentRange.cpp >index a3d4f044059dfd9a57b31929db8f112c15f62113..233ba3996592cef2a95d3b6f143432d56e3cd6b2 100644 >--- a/Source/WebCore/platform/network/ParsedContentRange.cpp >+++ b/Source/WebCore/platform/network/ParsedContentRange.cpp >@@ -31,7 +31,7 @@ > > namespace WebCore { > >-static bool areContentRangeValuesValid(int64_t firstBytePosition, int64_t lastBytePosition, int64_t instanceLength) >+static bool areContentRangeValuesValid(int64_t firstBytePosition, ParsedContentRange::BytePosition lastBytePosition, int64_t instanceLength) > { > // From <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html> > // 14.16 Content-Range >@@ -40,16 +40,16 @@ static bool areContentRangeValuesValid(int64_t firstBytePosition, int64_t lastBy > if (firstBytePosition < 0) > return false; > >- if (lastBytePosition < firstBytePosition) >+ if (lastBytePosition.value() < firstBytePosition) > return false; > > if (instanceLength == ParsedContentRange::UnknownLength) > return true; > >- return lastBytePosition < instanceLength; >+ return lastBytePosition.value() < instanceLength; > } > >-static bool parseContentRange(const String& headerValue, int64_t& firstBytePosition, int64_t& lastBytePosition, int64_t& instanceLength) >+static bool parseContentRange(const String& headerValue, int64_t& firstBytePosition, ParsedContentRange::BytePosition& lastBytePosition, int64_t& instanceLength) > { > // From <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html> > // 14.16 Content-Range >@@ -111,7 +111,8 @@ static bool parseContentRange(const String& headerValue, int64_t& firstBytePosit > > ParsedContentRange::ParsedContentRange(const String& headerValue) > { >- m_isValid = parseContentRange(headerValue, m_firstBytePosition, m_lastBytePosition, m_instanceLength); >+ if (!parseContentRange(headerValue, m_firstBytePosition, m_lastBytePosition, m_instanceLength)) >+ m_lastBytePosition = -1; > } > > ParsedContentRange::ParsedContentRange(int64_t firstBytePosition, int64_t lastBytePosition, int64_t instanceLength) >@@ -119,16 +120,17 @@ ParsedContentRange::ParsedContentRange(int64_t firstBytePosition, int64_t lastBy > , m_lastBytePosition(lastBytePosition) > , m_instanceLength(instanceLength) > { >- m_isValid = areContentRangeValuesValid(m_firstBytePosition, m_lastBytePosition, m_instanceLength); >+ if (!areContentRangeValuesValid(m_firstBytePosition, m_lastBytePosition, m_instanceLength)) >+ m_lastBytePosition = -1; > } > > String ParsedContentRange::headerValue() const > { >- if (!m_isValid) >+ if (!isValid()) > return String(); > if (m_instanceLength == UnknownLength) >- return makeString("bytes ", m_firstBytePosition, '-', m_lastBytePosition, "/*"); >- return makeString("bytes ", m_firstBytePosition, '-', m_lastBytePosition, '/', m_instanceLength); >+ return makeString("bytes ", m_firstBytePosition, '-', m_lastBytePosition.value(), "/*"); >+ return makeString("bytes ", m_firstBytePosition, '-', m_lastBytePosition.value(), '/', m_instanceLength); > } > > } >diff --git a/Source/WebCore/platform/network/ParsedContentRange.h b/Source/WebCore/platform/network/ParsedContentRange.h >index 5a0704bd4b96fdcba90dc14ca466cb8efd7de5c0..426a96d00783b5fca3c98391fbdcc52e6ab13583 100644 >--- a/Source/WebCore/platform/network/ParsedContentRange.h >+++ b/Source/WebCore/platform/network/ParsedContentRange.h >@@ -27,6 +27,7 @@ > #define ParsedContentRange_h > > #include <wtf/Forward.h> >+#include <wtf/Markable.h> > > namespace WebCore { > >@@ -36,22 +37,23 @@ public: > ParsedContentRange() { } > WEBCORE_EXPORT ParsedContentRange(int64_t firstBytePosition, int64_t lastBytePosition, int64_t instanceLength); > >- bool isValid() const { return m_isValid; } >+ bool isValid() const { return (bool)m_lastBytePosition; } > int64_t firstBytePosition() const { return m_firstBytePosition; } >- int64_t lastBytePosition() const { return m_lastBytePosition; } >+ int64_t lastBytePosition() const { return m_lastBytePosition.value(); } > int64_t instanceLength() const { return m_instanceLength; } > > WEBCORE_EXPORT String headerValue() const; > > enum { UnknownLength = std::numeric_limits<int64_t>::max() }; > >+ using BytePosition = Markable<int64_t, IntegralMarkableTraits<int64_t, -1>>; >+ > private: > template<typename T> static bool isPositive(T); > > int64_t m_firstBytePosition { 0 }; >- int64_t m_lastBytePosition { 0 }; >+ BytePosition m_lastBytePosition; > int64_t m_instanceLength { UnknownLength }; >- bool m_isValid { false }; > }; > > } >diff --git a/Source/WebCore/platform/network/ResourceResponseBase.cpp b/Source/WebCore/platform/network/ResourceResponseBase.cpp >index 20ac64d57034c69ea92bc7a43536f16d795ffa29..c9ccfde418c90bfaf366e8ab6a27feb667086667 100644 >--- a/Source/WebCore/platform/network/ResourceResponseBase.cpp >+++ b/Source/WebCore/platform/network/ResourceResponseBase.cpp >@@ -286,18 +286,18 @@ String ResourceResponseBase::sanitizeSuggestedFilename(const String& suggestedFi > > bool ResourceResponseBase::isSuccessful() const > { >- int code = httpStatusCode(); >+ uint16_t code = httpStatusCode(); > return code >= 200 && code < 300; > } > >-int ResourceResponseBase::httpStatusCode() const >+uint16_t ResourceResponseBase::httpStatusCode() const > { > lazyInit(CommonFieldsOnly); > > return m_httpStatusCode; > } > >-void ResourceResponseBase::setHTTPStatusCode(int statusCode) >+void ResourceResponseBase::setHTTPStatusCode(uint16_t statusCode) > { > lazyInit(CommonFieldsOnly); > >diff --git a/Source/WebCore/platform/network/ResourceResponseBase.h b/Source/WebCore/platform/network/ResourceResponseBase.h >index 9f1b3b2e7fc67935bf788d4977190dee5305855d..2c28d7fed3056dddf2725318bc674438b9022d4e 100644 >--- a/Source/WebCore/platform/network/ResourceResponseBase.h >+++ b/Source/WebCore/platform/network/ResourceResponseBase.h >@@ -48,7 +48,7 @@ public: > enum class Type : uint8_t { Basic, Cors, Default, Error, Opaque, Opaqueredirect }; > enum class Tainting : uint8_t { Basic, Cors, Opaque, Opaqueredirect }; > >- static bool isRedirectionStatusCode(int code) { return code == 301 || code == 302 || code == 303 || code == 307 || code == 308; } >+ static bool isRedirectionStatusCode(uint16_t code) { return code == 301 || code == 302 || code == 303 || code == 307 || code == 308; } > > struct CrossThreadData { > CrossThreadData(const CrossThreadData&) = delete; >@@ -60,7 +60,7 @@ public: > String mimeType; > long long expectedContentLength; > String textEncodingName; >- int httpStatusCode; >+ uint16_t httpStatusCode; > String httpStatusText; > String httpVersion; > HTTPHeaderMap httpHeaderFields; >@@ -89,8 +89,8 @@ public: > WEBCORE_EXPORT const String& textEncodingName() const; > WEBCORE_EXPORT void setTextEncodingName(const String& name); > >- WEBCORE_EXPORT int httpStatusCode() const; >- WEBCORE_EXPORT void setHTTPStatusCode(int); >+ WEBCORE_EXPORT uint16_t httpStatusCode() const; >+ WEBCORE_EXPORT void setHTTPStatusCode(uint16_t); > WEBCORE_EXPORT bool isRedirection() const; > > WEBCORE_EXPORT const String& httpStatusText() const; >@@ -240,7 +240,7 @@ private: > Tainting m_tainting { Tainting::Basic }; > > protected: >- int m_httpStatusCode { 0 }; >+ uint16_t m_httpStatusCode { 0 }; > }; > > inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { return ResourceResponseBase::compare(a, b); }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187460
:
346147
|
372680
|
372681
|
372682
|
372683
|
372684
|
372698
|
372702
|
372703
|
372704
|
372706
|
372707
|
372708
|
372712
|
372713
|
372716
|
372738
|
372783
|
372788
|
372789
|
372799
|
372802
|
373173
|
373175
|
373176
|
373194