Title: [239315] trunk/Source
Revision
239315
Author
ddkil...@apple.com
Date
2018-12-17 20:09:50 -0800 (Mon, 17 Dec 2018)

Log Message

clang-tidy: Fix unnecessary object copy in CPUMonitor::setCPULimit()
<https://webkit.org/b/192707>
<rdar://problem/46734926>

Reviewed by Daniel Bates.

Source/WebCore:

* platform/CPUMonitor.cpp:
(WebCore::CPUMonitor::setCPULimit):
* platform/CPUMonitor.h:
(WebCore::CPUMonitor::setCPULimit):
- Change parameter to const reference to fix unnecessary copies.

Source/WebKit:

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateCPUMonitorState):
- Pass m_cpuLimit directly since getting its value causes an
  identical std::optional<double> to be created unnecessarily.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239314 => 239315)


--- trunk/Source/WebCore/ChangeLog	2018-12-18 04:04:44 UTC (rev 239314)
+++ trunk/Source/WebCore/ChangeLog	2018-12-18 04:09:50 UTC (rev 239315)
@@ -1,3 +1,17 @@
+2018-12-17  David Kilzer  <ddkil...@apple.com>
+
+        clang-tidy: Fix unnecessary object copy in CPUMonitor::setCPULimit()
+        <https://webkit.org/b/192707>
+        <rdar://problem/46734926>
+
+        Reviewed by Daniel Bates.
+
+        * platform/CPUMonitor.cpp:
+        (WebCore::CPUMonitor::setCPULimit):
+        * platform/CPUMonitor.h:
+        (WebCore::CPUMonitor::setCPULimit):
+        - Change parameter to const reference to fix unnecessary copies.
+
 2018-12-17  Ryosuke Niwa  <rn...@webkit.org>
 
         offsetLeft and offsetParent should adjust across shadow boundaries

Modified: trunk/Source/WebCore/platform/CPUMonitor.cpp (239314 => 239315)


--- trunk/Source/WebCore/platform/CPUMonitor.cpp	2018-12-18 04:04:44 UTC (rev 239314)
+++ trunk/Source/WebCore/platform/CPUMonitor.cpp	2018-12-18 04:09:50 UTC (rev 239315)
@@ -35,7 +35,7 @@
 {
 }
 
-void CPUMonitor::setCPULimit(std::optional<double> cpuLimit)
+void CPUMonitor::setCPULimit(const std::optional<double>& cpuLimit)
 {
     if (m_cpuLimit == cpuLimit)
         return;

Modified: trunk/Source/WebCore/platform/CPUMonitor.h (239314 => 239315)


--- trunk/Source/WebCore/platform/CPUMonitor.h	2018-12-18 04:04:44 UTC (rev 239314)
+++ trunk/Source/WebCore/platform/CPUMonitor.h	2018-12-18 04:09:50 UTC (rev 239315)
@@ -37,7 +37,7 @@
     using ExceededCPULimitHandler = WTF::Function<void(double)>;
     WEBCORE_EXPORT CPUMonitor(Seconds checkInterval, ExceededCPULimitHandler&&);
 
-    WEBCORE_EXPORT void setCPULimit(std::optional<double>);
+    WEBCORE_EXPORT void setCPULimit(const std::optional<double>&);
 
 private:
     void timerFired();

Modified: trunk/Source/WebKit/ChangeLog (239314 => 239315)


--- trunk/Source/WebKit/ChangeLog	2018-12-18 04:04:44 UTC (rev 239314)
+++ trunk/Source/WebKit/ChangeLog	2018-12-18 04:09:50 UTC (rev 239315)
@@ -1,3 +1,16 @@
+2018-12-17  David Kilzer  <ddkil...@apple.com>
+
+        clang-tidy: Fix unnecessary object copy in CPUMonitor::setCPULimit()
+        <https://webkit.org/b/192707>
+        <rdar://problem/46734926>
+
+        Reviewed by Daniel Bates.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::updateCPUMonitorState):
+        - Pass m_cpuLimit directly since getting its value causes an
+          identical std::optional<double> to be created unnecessarily.
+
 2018-12-17  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [iOS] Focusing a large editable element always scrolls to the top of the element

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (239314 => 239315)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-12-18 04:04:44 UTC (rev 239314)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-12-18 04:09:50 UTC (rev 239315)
@@ -561,7 +561,7 @@
         // not want to report that a process has exceeded its background CPU limit even though most of the CPU time was used while the process was visible.
         m_cpuMonitor->setCPULimit(std::nullopt);
     }
-    m_cpuMonitor->setCPULimit(m_cpuLimit.value());
+    m_cpuMonitor->setCPULimit(m_cpuLimit);
 #else
     UNUSED_PARAM(reason);
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to