Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: lib/coreimpl/stopwatch_implementation.dart

Issue 10908066: - Removed named constructor Stopwatch.start() due to conflict with instance methods start(). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A simple implementation of the [Stopwatch] interface. 6 * A simple implementation of the [Stopwatch] interface.
7 */ 7 */
8 class StopwatchImplementation implements Stopwatch { 8 class StopwatchImplementation implements Stopwatch {
9 // The _start and _stop fields capture the time when [start] and [stop] 9 // The _start and _stop fields capture the time when [start] and [stop]
10 // are called respectively. 10 // are called respectively.
11 // If _start is null, then the [Stopwatch] has not been started yet. 11 // If _start is null, then the [Stopwatch] has not been started yet.
12 // If _stop is null, then the [Stopwatch] has not been stopped yet, 12 // If _stop is null, then the [Stopwatch] has not been stopped yet,
13 // or is running. 13 // or is running.
14 int _start; 14 int _start;
15 int _stop; 15 int _stop;
16 16
17 StopwatchImplementation() : _start = null, _stop = null {} 17 StopwatchImplementation() : _start = null, _stop = null {}
18 StopwatchImplementation.start() : _start = null, _stop = null {
19 start();
20 }
21 18
22 void start() { 19 void start() {
23 if (_start === null) { 20 if (_start === null) {
24 // This stopwatch has never been started. 21 // This stopwatch has never been started.
25 _start = _now(); 22 _start = _now();
26 } else { 23 } else {
27 if (_stop === null) { 24 if (_stop === null) {
28 return; 25 return;
29 } 26 }
30 // Restarting this stopwatch. Prepend the elapsed time to the current 27 // Restarting this stopwatch. Prepend the elapsed time to the current
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 63
67 int elapsedInMs() { 64 int elapsedInMs() {
68 return (elapsed() * 1000) ~/ frequency(); 65 return (elapsed() * 1000) ~/ frequency();
69 } 66 }
70 67
71 int frequency() => _frequency(); 68 int frequency() => _frequency();
72 69
73 external static int _frequency(); 70 external static int _frequency();
74 external static int _now(); 71 external static int _now();
75 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698