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

Unified Diff: sdk/lib/io/timer_impl.dart

Issue 106103007: If a new timer is the last timer to time out, don't run through the entire list of timers. (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: sdk/lib/io/timer_impl.dart
diff --git a/sdk/lib/io/timer_impl.dart b/sdk/lib/io/timer_impl.dart
index f03b6180e5e17c2c3c1788fb387e46da667e4565..a3eb9529a360a177f4e13de35d6f599afc4a1095 100644
--- a/sdk/lib/io/timer_impl.dart
+++ b/sdk/lib/io/timer_impl.dart
@@ -79,6 +79,12 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
// enqueued in order and notified in FIFO order.
void _addTimerToList() {
_Timer entry = _timers.isEmpty ? null : _timers.first;
+ // If timer is last, add to end.
+ if (entry == null || _timers.last._wakeupTime <= _wakeupTime) {
+ _timers.add(this);
+ return;
+ }
+ // Otherwise scan through and find the right position.
while (entry != null) {
if (_wakeupTime < entry._wakeupTime) {
entry.insertBefore(this);
« 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