@@ -993,12 +993,9 @@ class _SourcePart {
993993 }
994994
995995 void addImplicitClassNameOffset (String className, int offset) {
996- var offsets = _implicitClassNameOffsets[className];
997- if (offsets == null ) {
998- offsets = [];
999- _implicitClassNameOffsets[className] = offsets;
1000- }
1001- offsets.add (offset - _base);
996+ _implicitClassNameOffsets
997+ .putIfAbsent (className, () => [])
998+ .add (offset - _base);
1002999 }
10031000
10041001 void addImplicitThisOffset (int offset) {
@@ -1009,13 +1006,8 @@ class _SourcePart {
10091006 TypeParameterElement element,
10101007 SourceRange identifierRange,
10111008 ) {
1012- var typeParameter = _instanceTypeParameters[element];
1013- if (typeParameter == null ) {
1014- typeParameter = [];
1015- _instanceTypeParameters[element] = typeParameter;
1016- }
10171009 identifierRange = range.offsetBy (identifierRange, - _base);
1018- typeParameter .add (identifierRange);
1010+ _instanceTypeParameters. putIfAbsent (element, () => []) .add (identifierRange);
10191011 }
10201012
10211013 void addParameterOccurrence ({
@@ -1024,42 +1016,29 @@ class _SourcePart {
10241016 required Precedence parentPrecedence,
10251017 required bool inStringInterpolation,
10261018 }) {
1027- var occurrences = _parameters[parameter];
1028- if (occurrences == null ) {
1029- occurrences = [];
1030- _parameters[parameter] = occurrences;
1031- }
1032- occurrences.add (
1033- _ParameterOccurrence (
1034- baseOffset: _base,
1035- parentPrecedence: parentPrecedence,
1036- identifier: identifier,
1037- inStringInterpolation: inStringInterpolation,
1038- ),
1039- );
1019+ _parameters
1020+ .putIfAbsent (parameter, () => [])
1021+ .add (
1022+ _ParameterOccurrence (
1023+ baseOffset: _base,
1024+ parentPrecedence: parentPrecedence,
1025+ identifier: identifier,
1026+ inStringInterpolation: inStringInterpolation,
1027+ ),
1028+ );
10401029 }
10411030
10421031 void addTypeParameter (
10431032 TypeParameterElement element,
10441033 SourceRange identifierRange,
10451034 ) {
1046- var typeParameter = _typeParameters[element];
1047- if (typeParameter == null ) {
1048- typeParameter = [];
1049- _typeParameters[element] = typeParameter;
1050- }
10511035 identifierRange = range.offsetBy (identifierRange, - _base);
1052- typeParameter .add (identifierRange);
1036+ _typeParameters. putIfAbsent (element, () => []) .add (identifierRange);
10531037 }
10541038
10551039 void addVariable (VariableElement element, SourceRange identifierRange) {
1056- var ranges = _variables[element];
1057- if (ranges == null ) {
1058- ranges = [];
1059- _variables[element] = ranges;
1060- }
10611040 identifierRange = range.offsetBy (identifierRange, - _base);
1062- ranges .add (identifierRange);
1041+ _variables. putIfAbsent (element, () => []) .add (identifierRange);
10631042 }
10641043}
10651044
0 commit comments