Skip to content

Commit 1e96b6c

Browse files
authored
Correct a misused putIfAbsent call (flutter#109)
There is no need to assign within the callback for a `putIfAbsent` default. Refactor to the most idiomatic version today which is to use `??=` (since we don't ever assign a null value so we don't care about the distinction between a missing key and a key assigned to null) and return the value directly rather than putting it in the Map and then pulling it back out.
1 parent bd0f77f commit 1e96b6c

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

lib/src/analyzer.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,8 @@ class DeclarationIncludes extends Visitor {
716716
bool _allIncludes(rulesets) =>
717717
rulesets.every((rule) => rule is IncludeDirective || rule is NoOp);
718718

719-
CallMixin _createCallDeclMixin(MixinDefinition mixinDef) {
720-
callMap.putIfAbsent(mixinDef.name,
721-
() => callMap[mixinDef.name] = CallMixin(mixinDef, varDefs));
722-
return callMap[mixinDef.name];
723-
}
719+
CallMixin _createCallDeclMixin(MixinDefinition mixinDef) =>
720+
callMap[mixinDef.name] ??= CallMixin(mixinDef, varDefs);
724721

725722
@override
726723
void visitStyleSheet(StyleSheet ss) {

0 commit comments

Comments
 (0)