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

Unified Diff: pkg/compiler/lib/src/types/union_type_mask.dart

Issue 1611783003: dart2js: improve performance of TypeMask.intersection (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
Index: pkg/compiler/lib/src/types/union_type_mask.dart
diff --git a/pkg/compiler/lib/src/types/union_type_mask.dart b/pkg/compiler/lib/src/types/union_type_mask.dart
index 24a019144a87e3d76477db32517f90d80fc4f17a..6f8c81367584a09ac669ef49f8e5eebfb414dc86 100644
--- a/pkg/compiler/lib/src/types/union_type_mask.dart
+++ b/pkg/compiler/lib/src/types/union_type_mask.dart
@@ -152,12 +152,17 @@ class UnionTypeMask implements TypeMask {
TypeMask intersection(var other, ClassWorld classWorld) {
other = TypeMask.nonForwardingMask(other);
if (!other.isUnion && disjointMasks.contains(other)) return other;
+ if (other.isUnion && this == other) return this;
Siggi Cherem (dart-lang) 2016/01/21 01:07:12 These are common cases we hit during type propagat
asgerf 2016/01/21 01:15:45 I say add both.
List<TypeMask> intersections = <TypeMask>[];
for (TypeMask current in disjointMasks) {
if (other.isUnion) {
- for (FlatTypeMask flatOther in other.disjointMasks) {
- intersections.add(current.intersection(flatOther, classWorld));
+ if (other.disjointMasks.contains(current)) {
+ intersections.add(current);
+ } else {
+ for (FlatTypeMask flatOther in other.disjointMasks) {
+ intersections.add(current.intersection(flatOther, classWorld));
+ }
}
} else {
intersections.add(current.intersection(other, classWorld));

Powered by Google App Engine
This is Rietveld 408576698