Skip to content

Commit 39b60a6

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Flow analysis: inline _removePromotedAll at the call site.
There was only one call site, and the logic is clearer if all the logic is in one method. Change-Id: I59a6e0ce1e3345039146525a9bcd0b72025cbb5d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115006 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
1 parent c73df64 commit 39b60a6

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,19 @@ class FlowModel<Variable, Type> {
884884
/// be able to remove this method.
885885
FlowModel<Variable, Type> removePromotedAll(
886886
Iterable<Variable> variables, Set<Variable> referencedVariables) {
887-
Map<Variable, VariableModel<Type>> newVariableInfo =
888-
_removePromotedAll(variableInfo, variables, referencedVariables);
889-
890-
if (identical(newVariableInfo, variableInfo)) return this;
891-
887+
Map<Variable, VariableModel<Type>> newVariableInfo;
888+
for (Variable variable in variables) {
889+
assert(() {
890+
referencedVariables?.add(variable);
891+
return true;
892+
}());
893+
VariableModel<Type> info = variableInfo[variable];
894+
if (info?.promotedType != null) {
895+
(newVariableInfo ??= new Map<Variable, VariableModel<Type>>.from(
896+
variableInfo))[variable] = info.withPromotedType(null);
897+
}
898+
}
899+
if (newVariableInfo == null) return this;
892900
return new FlowModel<Variable, Type>._(reachable, newVariableInfo);
893901
}
894902

@@ -971,34 +979,6 @@ class FlowModel<Variable, Type> {
971979
return _updateVariableInfo(variable, newInfoForVar);
972980
}
973981

974-
/// Updates a "variableInfo" [map] to indicate that a set of [variable] is no
975-
/// longer promoted, treating the map as immutable.
976-
///
977-
/// If assertions are enabled and [referencedVariables] is not `null`, all
978-
/// variables in [variables] will be stored in [referencedVariables] as a side
979-
/// effect of this call.
980-
Map<Variable, VariableModel<Type>> _removePromotedAll(
981-
Map<Variable, VariableModel<Type>> map,
982-
Iterable<Variable> variables,
983-
Set<Variable> referencedVariables) {
984-
if (map.isEmpty) return const {};
985-
Map<Variable, VariableModel<Type>> result;
986-
for (Variable variable in variables) {
987-
assert(() {
988-
referencedVariables?.add(variable);
989-
return true;
990-
}());
991-
VariableModel<Type> info = map[variable];
992-
if (info?.promotedType != null) {
993-
(result ??=
994-
new Map<Variable, VariableModel<Type>>.from(map))[variable] =
995-
info.withPromotedType(null);
996-
}
997-
}
998-
if (result == null) return map;
999-
return result;
1000-
}
1001-
1002982
/// Returns a new [FlowModel] where the information for [variable] is replaced
1003983
/// with [model].
1004984
FlowModel<Variable, Type> _updateVariableInfo(

0 commit comments

Comments
 (0)