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); |