Title: [229935] trunk/Source/WebCore
Revision
229935
Author
cdu...@apple.com
Date
2018-03-23 16:46:50 -0700 (Fri, 23 Mar 2018)

Log Message

NetworkStateNotifier::updateStateWithoutNotifying() is inefficient
https://bugs.webkit.org/show_bug.cgi?id=183760
<rdar://problem/37093299>

Reviewed by Ryosuke Niwa.

Update NetworkStateNotifier::updateStateWithoutNotifying() to stop calling
SCDynamicStoreCopyKeyList(). SCDynamicStoreCopyKeyList() is expensive as it
expects its key parameter to be a regular _expression_ and it can match several
keys. It is also unnecessary in our case since we already have an exact key.
We now call the more efficient SCDynamicStoreCopyValue() instead, which is
the right thing to call when we have an exact key.

This change was suggested by the SC team.

This was tested manually as there is no easy way to write an automated test
for this.

In a follow-up, I also plan to call this code in the UIProcess (or NetworkProcess)
to avoid calling it once per WebProcess.

* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::updateStateWithoutNotifying):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229934 => 229935)


--- trunk/Source/WebCore/ChangeLog	2018-03-23 23:41:59 UTC (rev 229934)
+++ trunk/Source/WebCore/ChangeLog	2018-03-23 23:46:50 UTC (rev 229935)
@@ -1,3 +1,29 @@
+2018-03-23  Chris Dumez  <cdu...@apple.com>
+
+        NetworkStateNotifier::updateStateWithoutNotifying() is inefficient
+        https://bugs.webkit.org/show_bug.cgi?id=183760
+        <rdar://problem/37093299>
+
+        Reviewed by Ryosuke Niwa.
+
+        Update NetworkStateNotifier::updateStateWithoutNotifying() to stop calling
+        SCDynamicStoreCopyKeyList(). SCDynamicStoreCopyKeyList() is expensive as it
+        expects its key parameter to be a regular _expression_ and it can match several
+        keys. It is also unnecessary in our case since we already have an exact key.
+        We now call the more efficient SCDynamicStoreCopyValue() instead, which is
+        the right thing to call when we have an exact key.
+
+        This change was suggested by the SC team.
+
+        This was tested manually as there is no easy way to write an automated test
+        for this.
+
+        In a follow-up, I also plan to call this code in the UIProcess (or NetworkProcess)
+        to avoid calling it once per WebProcess.
+
+        * platform/network/mac/NetworkStateNotifierMac.cpp:
+        (WebCore::NetworkStateNotifier::updateStateWithoutNotifying):
+
 2018-03-23  Daniel Bates  <daba...@apple.com>
 
         Unreviewed, rolling out r229868.

Modified: trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp (229934 => 229935)


--- trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp	2018-03-23 23:41:59 UTC (rev 229934)
+++ trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp	2018-03-23 23:46:50 UTC (rev 229935)
@@ -61,8 +61,7 @@
             continue;
 
         auto key = adoptCF(SCDynamicStoreKeyCreateNetworkInterfaceEntity(0, kSCDynamicStoreDomainState, interfaceName, kSCEntNetIPv4));
-        auto keyList = adoptCF(SCDynamicStoreCopyKeyList(m_store.get(), key.get()));
-        if (keyList && CFArrayGetCount(keyList.get())) {
+        if (SCDynamicStoreCopyValue(m_store.get(), key.get())) {
             m_isOnLine = true;
             return;
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to