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

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

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 6 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/flat_type_mask.dart
diff --git a/pkg/compiler/lib/src/types/flat_type_mask.dart b/pkg/compiler/lib/src/types/flat_type_mask.dart
index 2fa32efb6fce006ae09cc573d902fe31a2d04181..17d0fc5d418852d67711f78d127c047c45816b67 100644
--- a/pkg/compiler/lib/src/types/flat_type_mask.dart
+++ b/pkg/compiler/lib/src/types/flat_type_mask.dart
@@ -57,7 +57,14 @@ class FlatTypeMask implements TypeMask {
if (((flags >> 1) == SUBCLASS) && !world.hasAnySubclass(base)) {
flags = (flags & 0x1) | (EXACT << 1);
}
- return new FlatTypeMask.internal(base, flags);
+ Map<ClassElement, TypeMask> cachedMasks =
+ world.canonicalizedTypeMasks[flags];
+ if (cachedMasks == null) {
+ world.canonicalizedTypeMasks[flags] = cachedMasks =
+ <ClassElement, TypeMask>{};
+ }
+ return cachedMasks.putIfAbsent(base,
+ () => new FlatTypeMask.internal(base, flags));
}
bool get isEmpty => (flags >> 1) == EMPTY;
@@ -634,9 +641,12 @@ class FlatTypeMask implements TypeMask {
subclassesToCheck.any(needsNoSuchMethod);
}
- Element locateSingleElement(Selector selector, Compiler compiler) {
+ Element locateSingleElement(Selector selector,
+ TypeMask mask,
+ Compiler compiler) {
if (isEmpty) return null;
- Iterable<Element> targets = compiler.world.allFunctions.filter(selector);
+ Iterable<Element> targets =
+ compiler.world.allFunctions.filter(selector, mask);
if (targets.length != 1) return null;
Element result = targets.first;
ClassElement enclosing = result.enclosingClass;
@@ -648,6 +658,7 @@ class FlatTypeMask implements TypeMask {
}
bool operator ==(var other) {
+ if (identical(this, other)) return true;
if (other is !FlatTypeMask) return false;
FlatTypeMask otherMask = other;
return (flags == otherMask.flags) && (base == otherMask.base);
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart ('k') | pkg/compiler/lib/src/types/forwarding_type_mask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698