| OLD | NEW |
| (Empty) | |
| 1 part of angular.watch_group; |
| 2 |
| 3 |
| 4 class _LinkedListItem<I extends _LinkedListItem> { |
| 5 I _previous, _next; |
| 6 } |
| 7 |
| 8 class _LinkedList<L extends _LinkedList> { |
| 9 L _head, _tail; |
| 10 |
| 11 static _Handler _add(_Handler list, _LinkedListItem item) { |
| 12 assert(item._next == null); |
| 13 assert(item._previous == null); |
| 14 if (list._tail == null) { |
| 15 list._head = list._tail = item; |
| 16 } else { |
| 17 item._previous = list._tail; |
| 18 list._tail._next = item; |
| 19 list._tail = item; |
| 20 } |
| 21 return item; |
| 22 } |
| 23 |
| 24 static bool _isEmpty(_Handler list) => list._head == null; |
| 25 |
| 26 static void _remove(_Handler list, _Handler item) { |
| 27 var previous = item._previous; |
| 28 var next = item._next; |
| 29 |
| 30 if (previous == null) list._head = next; else previous._next = next; |
| 31 if (next == null) list._tail = previous; else next._previous = previous; |
| 32 } |
| 33 } |
| 34 |
| 35 class _ArgHandlerList { |
| 36 _ArgHandler _argHandlerHead, _argHandlerTail; |
| 37 |
| 38 static _Handler _add(_ArgHandlerList list, _ArgHandler item) { |
| 39 assert(item._nextArgHandler == null); |
| 40 assert(item._previousArgHandler == null); |
| 41 if (list._argHandlerTail == null) { |
| 42 list._argHandlerHead = list._argHandlerTail = item; |
| 43 } else { |
| 44 item._previousArgHandler = list._argHandlerTail; |
| 45 list._argHandlerTail._nextArgHandler = item; |
| 46 list._argHandlerTail = item; |
| 47 } |
| 48 return item; |
| 49 } |
| 50 |
| 51 static bool _isEmpty(_InvokeHandler list) => list._argHandlerHead == null; |
| 52 |
| 53 static void _remove(_InvokeHandler list, _ArgHandler item) { |
| 54 var previous = item._previousArgHandler; |
| 55 var next = item._nextArgHandler; |
| 56 |
| 57 if (previous == null) list._argHandlerHead = next; else previous._nextAr
gHandler = next; |
| 58 if (next == null) list._argHandlerTail = previous; else next._previousAr
gHandler = previous; |
| 59 } |
| 60 } |
| 61 |
| 62 class _WatchList { |
| 63 Watch _watchHead, _watchTail; |
| 64 |
| 65 static Watch _add(_WatchList list, Watch item) { |
| 66 assert(item._nextWatch == null); |
| 67 assert(item._previousWatch == null); |
| 68 if (list._watchTail == null) { |
| 69 list._watchHead = list._watchTail = item; |
| 70 } else { |
| 71 item._previousWatch = list._watchTail; |
| 72 list._watchTail._nextWatch = item; |
| 73 list._watchTail = item; |
| 74 } |
| 75 return item; |
| 76 } |
| 77 |
| 78 static bool _isEmpty(_Handler list) => list._watchHead == null; |
| 79 |
| 80 static void _remove(_Handler list, Watch item) { |
| 81 var previous = item._previousWatch; |
| 82 var next = item._nextWatch; |
| 83 |
| 84 if (previous == null) list._watchHead = next; else previous._nextWatch =
next; |
| 85 if (next == null) list._watchTail = previous; else next._previousWatch =
previous; |
| 86 } |
| 87 } |
| 88 |
| 89 abstract class _EvalWatchList { |
| 90 _EvalWatchRecord _evalWatchHead, _evalWatchTail; |
| 91 _EvalWatchRecord get _marker; |
| 92 |
| 93 static _EvalWatchRecord _add(_EvalWatchList list, _EvalWatchRecord item) { |
| 94 assert(item._nextEvalWatch == null); |
| 95 assert(item._previousEvalWatch == null); |
| 96 var prev = list._evalWatchTail; |
| 97 var next = prev._nextEvalWatch; |
| 98 |
| 99 if (prev == list._marker) { |
| 100 list._evalWatchHead = list._evalWatchTail = item; |
| 101 prev = prev._previousEvalWatch; |
| 102 } |
| 103 item._nextEvalWatch = next; |
| 104 item._previousEvalWatch = prev; |
| 105 |
| 106 if (prev != null) prev._nextEvalWatch = item; |
| 107 if (next != null) next._previousEvalWatch = item; |
| 108 |
| 109 return list._evalWatchTail = item; |
| 110 } |
| 111 |
| 112 static bool _isEmpty(_EvalWatchList list) => list._evalWatchHead == null; |
| 113 |
| 114 static void _remove(_EvalWatchList list, _EvalWatchRecord item) { |
| 115 assert(item.watchGrp == list); |
| 116 var prev = item._previousEvalWatch; |
| 117 var next = item._nextEvalWatch; |
| 118 |
| 119 if (list._evalWatchHead == list._evalWatchTail) { |
| 120 list._evalWatchHead = list._evalWatchTail = list._marker; |
| 121 list._marker |
| 122 .._nextEvalWatch = next |
| 123 .._previousEvalWatch = prev; |
| 124 if (prev != null) prev._nextEvalWatch = list._marker; |
| 125 if (next != null) next._previousEvalWatch = list._marker; |
| 126 } else { |
| 127 if (item == list._evalWatchHead) list._evalWatchHead = next; |
| 128 if (item == list._evalWatchTail) list._evalWatchTail = prev; |
| 129 if (prev != null) prev._nextEvalWatch = next; |
| 130 if (next != null) next._previousEvalWatch = prev; |
| 131 } |
| 132 } |
| 133 } |
| 134 |
| 135 class _WatchGroupList { |
| 136 WatchGroup _watchGroupHead, _watchGroupTail; |
| 137 |
| 138 static WatchGroup _add(_WatchGroupList list, WatchGroup item) { |
| 139 assert(item._nextWatchGroup == null); |
| 140 assert(item._previousWatchGroup == null); |
| 141 if (list._watchGroupTail == null) { |
| 142 list._watchGroupHead = list._watchGroupTail = item; |
| 143 } else { |
| 144 item._previousWatchGroup = list._watchGroupTail; |
| 145 list._watchGroupTail._nextWatchGroup = item; |
| 146 list._watchGroupTail = item; |
| 147 } |
| 148 return item; |
| 149 } |
| 150 |
| 151 static bool _isEmpty(_WatchGroupList list) => list._watchGroupHead == null; |
| 152 |
| 153 static void _remove(_WatchGroupList list, WatchGroup item) { |
| 154 var previous = item._previousWatchGroup; |
| 155 var next = item._nextWatchGroup; |
| 156 |
| 157 if (previous == null) list._watchGroupHead = next; else previous._nextWa
tchGroup = next; |
| 158 if (next == null) list._watchGroupTail = previous; else next._previousWa
tchGroup = previous; |
| 159 } |
| 160 } |
| OLD | NEW |