Title: [174717] trunk/Source/WebCore
- Revision
- 174717
- Author
- [email protected]
- Date
- 2014-10-14 17:44:36 -0700 (Tue, 14 Oct 2014)
Log Message
[Mac] Fix inefficiencies in ResourceResponse::platformLazyInit(InitLevel)
https://bugs.webkit.org/show_bug.cgi?id=137721
Reviewed by Geoffrey Garen.
There were several inefficiencies with the Mac implementation of
ResourceResponse::platformLazyInit(InitLevel):
1. We end up initializing uncommon fields even if called with
'CommonFieldsOnly' initLevel.
2. If called with 'AllFields' initLevel (and if currently
uninitialized), we end up populating m_httpHeaderFields twice, once
with only the common headers, then a second time with ALL the
headers. We can skip the common-header case in this case to avoid
wasting CPU time.
This patch addresses both inefficiencies and cleans up the code a
little bit to reduce variable scope and to use fast enumeration of
header names.
As a result, we spend almost twice as little time in platformLazyInit()
when loading msn.com (~30ms -> ~18ms).
No new tests, no behavior change.
* platform/network/mac/ResourceResponseMac.mm:
(WebCore::ResourceResponse::platformLazyInit):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (174716 => 174717)
--- trunk/Source/WebCore/ChangeLog 2014-10-15 00:42:57 UTC (rev 174716)
+++ trunk/Source/WebCore/ChangeLog 2014-10-15 00:44:36 UTC (rev 174717)
@@ -1,3 +1,32 @@
+2014-10-14 Chris Dumez <[email protected]>
+
+ [Mac] Fix inefficiencies in ResourceResponse::platformLazyInit(InitLevel)
+ https://bugs.webkit.org/show_bug.cgi?id=137721
+
+ Reviewed by Geoffrey Garen.
+
+ There were several inefficiencies with the Mac implementation of
+ ResourceResponse::platformLazyInit(InitLevel):
+ 1. We end up initializing uncommon fields even if called with
+ 'CommonFieldsOnly' initLevel.
+ 2. If called with 'AllFields' initLevel (and if currently
+ uninitialized), we end up populating m_httpHeaderFields twice, once
+ with only the common headers, then a second time with ALL the
+ headers. We can skip the common-header case in this case to avoid
+ wasting CPU time.
+
+ This patch addresses both inefficiencies and cleans up the code a
+ little bit to reduce variable scope and to use fast enumeration of
+ header names.
+
+ As a result, we spend almost twice as little time in platformLazyInit()
+ when loading msn.com (~30ms -> ~18ms).
+
+ No new tests, no behavior change.
+
+ * platform/network/mac/ResourceResponseMac.mm:
+ (WebCore::ResourceResponse::platformLazyInit):
+
2014-10-14 Zalan Bujtas <[email protected]>
REGRESSION (Safari 7.1/8.0): Border-radius and overflow hidden renders incorrectly.
Modified: trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm (174716 => 174717)
--- trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm 2014-10-15 00:42:57 UTC (rev 174716)
+++ trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm 2014-10-15 00:44:36 UTC (rev 174717)
@@ -135,12 +135,13 @@
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();
m_httpStatusCode = [httpResponse statusCode];
-
- NSDictionary *headers = [httpResponse allHeaderFields];
- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(commonHeaderFields); ++i) {
- if (NSString* headerValue = [headers objectForKey:commonHeaderFields[i]])
- m_httpHeaderFields.set(String(commonHeaderFields[i]), headerValue);
+ if (initLevel < AllFields) {
+ NSDictionary *headers = [httpResponse allHeaderFields];
+ for (unsigned i = 0; i < WTF_ARRAY_LENGTH(commonHeaderFields); ++i) {
+ if (NSString* headerValue = [headers objectForKey:commonHeaderFields[i]])
+ m_httpHeaderFields.set(String(commonHeaderFields[i]), headerValue);
+ }
}
} else
m_httpStatusCode = 0;
@@ -148,21 +149,18 @@
[pool drain];
}
- if (m_initLevel < AllFields) {
+ if (m_initLevel < AllFields && initLevel == AllFields) {
if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();
-
- RetainPtr<NSString> httpStatusLine = adoptNS(wkCopyNSURLResponseStatusLine(m_nsResponse.get()));
- if (httpStatusLine)
+ if (RetainPtr<NSString> httpStatusLine = adoptNS(wkCopyNSURLResponseStatusLine(httpResponse)))
m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(httpStatusLine.get());
else
- m_httpStatusText = "OK";
+ m_httpStatusText = AtomicString("OK", AtomicString::ConstructFromLiteral);
NSDictionary *headers = [httpResponse allHeaderFields];
- NSEnumerator *e = [headers keyEnumerator];
- while (NSString *name = [e nextObject])
+ for (NSString *name in headers)
m_httpHeaderFields.set(String(name), [headers objectForKey:name]);
[pool drain];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes