@@ -139,9 +139,10 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
139
139
}
140
140
141
141
Watch watch (AST expression, ReactionFn reactionFn) {
142
- WatchRecord <_Handler > watchRecord =
143
- _cache.putIfAbsent (expression.expression,
144
- () => expression.setupWatch (this ));
142
+ WatchRecord <_Handler > watchRecord = _cache[expression.expression];
143
+ if (watchRecord == null ) {
144
+ _cache[expression.expression] = watchRecord = expression.setupWatch (this );
145
+ }
145
146
return watchRecord.handler.addReactionFn (reactionFn);
146
147
}
147
148
@@ -160,8 +161,10 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
160
161
_fieldCost++ ;
161
162
fieldHandler.watchRecord = watchRecord;
162
163
163
- WatchRecord <_Handler > lhsWR = _cache.putIfAbsent (lhs.expression,
164
- () => lhs.setupWatch (this ));
164
+ WatchRecord <_Handler > lhsWR = _cache[lhs.expression];
165
+ if (lhsWR == null ) {
166
+ lhsWR = _cache[lhs.expression] = lhs.setupWatch (this );
167
+ }
165
168
166
169
// We set a field forwarding handler on LHS. This will allow the change
167
170
// objects to propagate to the current WatchRecord.
@@ -177,8 +180,10 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
177
180
var watchRecord = _changeDetector.watch (null , null , collectionHandler);
178
181
_collectionCost++ ;
179
182
collectionHandler.watchRecord = watchRecord;
180
- WatchRecord <_Handler > astWR = _cache.putIfAbsent (ast.expression,
181
- () => ast.setupWatch (this ));
183
+ WatchRecord <_Handler > astWR = _cache[ast.expression];
184
+ if (astWR == null ) {
185
+ astWR = _cache[ast.expression] = ast.setupWatch (this );
186
+ }
182
187
183
188
// We set a field forwarding handler on LHS. This will allow the change
184
189
// objects to propagate to the current WatchRecord.
@@ -229,26 +234,32 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList {
229
234
invokeHandler.watchRecord = evalWatchRecord;
230
235
231
236
if (lhsAST != null ) {
232
- var lhsWR = _cache.putIfAbsent (lhsAST.expression,
233
- () => lhsAST.setupWatch (this ));
237
+ var lhsWR = _cache[lhsAST.expression];
238
+ if (lhsWR == null ) {
239
+ lhsWR = _cache[lhsAST.expression] = lhsAST.setupWatch (this );
240
+ }
234
241
lhsWR.handler.addForwardHandler (invokeHandler);
235
242
invokeHandler.acceptValue (lhsWR.currentValue);
236
243
}
237
244
238
245
// Convert the args from AST to WatchRecords
239
246
for (var i = 0 ; i < argsAST.length; i++ ) {
240
247
var ast = argsAST[i];
241
- WatchRecord <_Handler > record =
242
- _cache.putIfAbsent (ast.expression, () => ast.setupWatch (this ));
248
+ WatchRecord <_Handler > record = _cache[ast.expression];
249
+ if (record == null ) {
250
+ record = _cache[ast.expression] = ast.setupWatch (this );
251
+ }
243
252
_ArgHandler handler = new _PositionalArgHandler (this , evalWatchRecord, i);
244
253
_ArgHandlerList ._add (invokeHandler, handler);
245
254
record.handler.addForwardHandler (handler);
246
255
handler.acceptValue (record.currentValue);
247
256
}
248
257
249
258
namedArgsAST.forEach ((Symbol name, AST ast) {
250
- WatchRecord <_Handler > record = _cache.putIfAbsent (ast.expression,
251
- () => ast.setupWatch (this ));
259
+ WatchRecord <_Handler > record = _cache[ast.expression];
260
+ if (record == null ) {
261
+ record = _cache[ast.expression] = ast.setupWatch (this );
262
+ }
252
263
_ArgHandler handler = new _NamedArgHandler (this , evalWatchRecord, name);
253
264
_ArgHandlerList ._add (invokeHandler, handler);
254
265
record.handler.addForwardHandler (handler);
0 commit comments