@@ -54,7 +54,6 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
54
54
final ChangeDetectorGroup <_Handler > _changeDetector;
55
55
/** A cache for sharing sub expression watching. Watching `a` and `a.b` will
56
56
* watch `a` only once. */
57
- final Map <String , WatchRecord <_Handler >> _cache;
58
57
final RootWatchGroup _rootGroup;
59
58
60
59
/// STATS: Number of field watchers which are in use.
@@ -108,7 +107,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
108
107
WatchGroup _prevWatchGroup, _nextWatchGroup;
109
108
110
109
WatchGroup ._child (_parentWatchGroup, this ._changeDetector, this .context,
111
- this ._cache, this . _rootGroup)
110
+ this ._rootGroup)
112
111
: _parentWatchGroup = _parentWatchGroup,
113
112
id = '${_parentWatchGroup .id }.${_parentWatchGroup ._nextChildId ++}'
114
113
{
@@ -119,8 +118,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
119
118
WatchGroup ._root (this ._changeDetector, this .context)
120
119
: id = '' ,
121
120
_rootGroup = null ,
122
- _parentWatchGroup = null ,
123
- _cache = new HashMap <String , WatchRecord <_Handler >>()
121
+ _parentWatchGroup = null
124
122
{
125
123
_marker.watchGrp = this ;
126
124
_evalWatchTail = _evalWatchHead = _marker;
@@ -139,10 +137,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
139
137
}
140
138
141
139
Watch watch (AST expression, ReactionFn reactionFn) {
142
- WatchRecord <_Handler > watchRecord = _cache[expression.expression];
143
- if (watchRecord == null ) {
144
- _cache[expression.expression] = watchRecord = expression.setupWatch (this );
145
- }
140
+ WatchRecord <_Handler > watchRecord = expression.setupWatch (this );
146
141
return watchRecord.handler.addReactionFn (reactionFn);
147
142
}
148
143
@@ -161,10 +156,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
161
156
_fieldCost++ ;
162
157
fieldHandler.watchRecord = watchRecord;
163
158
164
- WatchRecord <_Handler > lhsWR = _cache[lhs.expression];
165
- if (lhsWR == null ) {
166
- lhsWR = _cache[lhs.expression] = lhs.setupWatch (this );
167
- }
159
+ WatchRecord <_Handler > lhsWR = lhs.setupWatch (this );
168
160
169
161
// We set a field forwarding handler on LHS. This will allow the change
170
162
// objects to propagate to the current WatchRecord.
@@ -180,10 +172,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
180
172
var watchRecord = _changeDetector.watch (null , null , collectionHandler);
181
173
_collectionCost++ ;
182
174
collectionHandler.watchRecord = watchRecord;
183
- WatchRecord <_Handler > astWR = _cache[ast.expression];
184
- if (astWR == null ) {
185
- astWR = _cache[ast.expression] = ast.setupWatch (this );
186
- }
175
+ WatchRecord <_Handler > astWR = ast.setupWatch (this );
187
176
188
177
// We set a field forwarding handler on LHS. This will allow the change
189
178
// objects to propagate to the current WatchRecord.
@@ -234,32 +223,23 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
234
223
invokeHandler.watchRecord = evalWatchRecord;
235
224
236
225
if (lhsAST != null ) {
237
- var lhsWR = _cache[lhsAST.expression];
238
- if (lhsWR == null ) {
239
- lhsWR = _cache[lhsAST.expression] = lhsAST.setupWatch (this );
240
- }
226
+ var lhsWR = lhsAST.setupWatch (this );
241
227
lhsWR.handler.addForwardHandler (invokeHandler);
242
228
invokeHandler.acceptValue (lhsWR.currentValue);
243
229
}
244
230
245
231
// Convert the args from AST to WatchRecords
246
232
for (var i = 0 ; i < argsAST.length; i++ ) {
247
233
var ast = argsAST[i];
248
- WatchRecord <_Handler > record = _cache[ast.expression];
249
- if (record == null ) {
250
- record = _cache[ast.expression] = ast.setupWatch (this );
251
- }
234
+ WatchRecord <_Handler > record = ast.setupWatch (this );
252
235
_ArgHandler handler = new _PositionalArgHandler (this , evalWatchRecord, i);
253
236
_ArgHandlerList ._add (invokeHandler, handler);
254
237
record.handler.addForwardHandler (handler);
255
238
handler.acceptValue (record.currentValue);
256
239
}
257
240
258
241
namedArgsAST.forEach ((Symbol name, AST ast) {
259
- WatchRecord <_Handler > record = _cache[ast.expression];
260
- if (record == null ) {
261
- record = _cache[ast.expression] = ast.setupWatch (this );
262
- }
242
+ WatchRecord <_Handler > record = ast.setupWatch (this );
263
243
_ArgHandler handler = new _NamedArgHandler (this , evalWatchRecord, name);
264
244
_ArgHandlerList ._add (invokeHandler, handler);
265
245
record.handler.addForwardHandler (handler);
@@ -301,7 +281,6 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
301
281
this ,
302
282
_changeDetector.newGroup (),
303
283
context == null ? this .context : context,
304
- new HashMap <String , WatchRecord <_Handler >>(),
305
284
_rootGroup == null ? this : _rootGroup);
306
285
_WatchGroupList ._add (this , childGroup);
307
286
var marker = childGroup._marker;
@@ -581,7 +560,6 @@ abstract class _Handler implements _LinkedList, _LinkedListItem, _WatchList {
581
560
_releaseWatch ();
582
561
// Remove ourselves from cache, or else new registrations will go to us,
583
562
// but we are dead
584
- watchGrp._cache.remove (expression);
585
563
586
564
if (forwardingHandler != null ) {
587
565
// TODO(misko): why do we need this check?
0 commit comments