Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 2876533004: Add FunctionType.getNamedParameter. (Closed)
Patch Set: Extract namedParameters[pivot] into a local variable Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 73c98cc0ed765e42978d4ff155b6b30106497f2d..34b001722e5581411af4b7797ad98d86c41c5d9a 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -625,21 +625,7 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
}
DartType _getNamedParameterType(FunctionType functionType, String name) {
- // TODO(paulberry): is there a kernel function that does this binary search?
- int lower = 0;
- int upper = functionType.namedParameters.length - 1;
- while (lower <= upper) {
- int pivot = (lower + upper) ~/ 2;
- int comparison = name.compareTo(functionType.namedParameters[pivot].name);
- if (comparison == 0) {
- return functionType.namedParameters[pivot].type;
- } else if (comparison < 0) {
- upper = pivot - 1;
- } else {
- lower = pivot + 1;
- }
- }
- return const DynamicType();
+ return functionType.getNamedParameter(name) ?? const DynamicType();
}
DartType _getPositionalParameterType(FunctionType functionType, int i) {
« no previous file with comments | « no previous file | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698