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

Unified Diff: tools/dom/src/native_DOMImplementation.dart

Issue 111613002: Fix static-ness of const fields in timer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/native_DOMImplementation.dart
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart
index d4ed796b16201c2d1f1134cdffc56c21ab9959f3..23d9931a76c700176e68c5eb7b4115d9c78a8b67 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -531,26 +531,26 @@ final _pureIsolateUriBaseClosure = () {
};
class _Timer implements Timer {
- const int _STATE_TIMEOUT = 0;
- const int _STATE_INTERVAL = 1;
- var _state;
+ static const int _STATE_TIMEOUT = 0;
+ static const int _STATE_INTERVAL = 1;
+ int _state;
_Timer(int milliSeconds, void callback(Timer timer), bool repeating) {
if (repeating) {
- _state = window._setInterval(() {
+ _state = (window._setInterval(() {
callback(this);
- }, milliSeconds) * 2 + _STATE_INTERVAL;
+ }, milliSeconds) << 1) | _STATE_INTERVAL;
} else {
- _state = window._setTimeout(() {
+ _state = (window._setTimeout(() {
_state = null;
callback(this);
- }, milliSeconds) * 2 + _STATE_TIMEOUT;
+ }, milliSeconds) << 1) | _STATE_TIMEOUT;
}
}
void cancel() {
if (_state == null) return;
- int id = _state ~/ 2;
+ int id = _state >> 1;
if ((_state & 1) == _STATE_TIMEOUT) {
window._clearTimeout(id);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698