Skip to content

Commit

Permalink
[dart2js, ddc] Avoid multiple _getKind() calls
Browse files Browse the repository at this point in the history
Add a local variable for the result.

Change-Id: Iff4002ecd3d491c9b12b3e7baf98394612983520
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323710
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and Commit Queue committed Sep 1, 2023
1 parent 4b3e1a2 commit 83bbef0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sdk/lib/_internal/js_shared/lib/rti.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,9 @@ bool _installSpecializedIsTest(Object? object) {
}

Rti unstarred = Rti._unstar(testRti);
int unstarredKind = Rti._getKind(unstarred);

if (Rti._getKind(unstarred) == Rti.kindFutureOr) {
if (unstarredKind == Rti.kindFutureOr) {
return _finishIsFn(testRti, object, RAW_DART_FUNCTION_REF(_isFutureOr));
}

Expand All @@ -1130,7 +1131,7 @@ bool _installSpecializedIsTest(Object? object) {
return _finishIsFn(testRti, object, isFn);
}

if (Rti._getKind(unstarred) == Rti.kindInterface) {
if (unstarredKind == Rti.kindInterface) {
String name = Rti._getInterfaceName(unstarred);
var arguments = Rti._getInterfaceTypeArguments(unstarred);
// This recognizes interface types instantiated with Top, which includes the
Expand All @@ -1152,7 +1153,7 @@ bool _installSpecializedIsTest(Object? object) {
testRti, object, RAW_DART_FUNCTION_REF(_isTestViaProperty));
}
// fall through to general implementation.
} else if (Rti._getKind(unstarred) == Rti.kindRecord) {
} else if (unstarredKind == Rti.kindRecord) {
isFn = _recordSpecializedIsTest(unstarred);
return _finishIsFn(testRti, object, isFn);
}
Expand Down

0 comments on commit 83bbef0

Please sign in to comment.