Title: [190247] trunk/Source/WTF
Revision
190247
Author
commit-qu...@webkit.org
Date
2015-09-25 10:51:33 -0700 (Fri, 25 Sep 2015)

Log Message

Simplify Stopwatch::elapsedTime
https://bugs.webkit.org/show_bug.cgi?id=149538

Patch by Joseph Pecoraro <pecor...@apple.com> on 2015-09-25
Reviewed by Darin Adler.

* wtf/Stopwatch.h:
(WTF::Stopwatch::elapsedTime):
Simplify by not starting/stopping but just computing without updating members.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (190246 => 190247)


--- trunk/Source/WTF/ChangeLog	2015-09-25 17:51:28 UTC (rev 190246)
+++ trunk/Source/WTF/ChangeLog	2015-09-25 17:51:33 UTC (rev 190247)
@@ -1,3 +1,14 @@
+2015-09-25  Joseph Pecoraro  <pecor...@apple.com>
+
+        Simplify Stopwatch::elapsedTime
+        https://bugs.webkit.org/show_bug.cgi?id=149538
+
+        Reviewed by Darin Adler.
+
+        * wtf/Stopwatch.h:
+        (WTF::Stopwatch::elapsedTime):
+        Simplify by not starting/stopping but just computing without updating members.
+
 2015-09-25  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Unreviewed build fix.

Modified: trunk/Source/WTF/wtf/Stopwatch.h (190246 => 190247)


--- trunk/Source/WTF/wtf/Stopwatch.h	2015-09-25 17:51:28 UTC (rev 190246)
+++ trunk/Source/WTF/wtf/Stopwatch.h	2015-09-25 17:51:33 UTC (rev 190247)
@@ -75,15 +75,10 @@
 
 inline double Stopwatch::elapsedTime()
 {
-    bool shouldSuspend = !std::isnan(m_lastStartTime);
-    if (shouldSuspend)
-        stop();
+    if (!isActive())
+        return m_elapsedTime;
 
-    double elapsedTime = m_elapsedTime;
-
-    if (shouldSuspend)
-        start();
-    return elapsedTime;
+    return m_elapsedTime + (monotonicallyIncreasingTime() - m_lastStartTime);
 }
 
 } // namespace WTF
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to