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

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_rti.dart

Issue 2326943003: Reuse expensive string in js_rti (Closed)
Patch Set: Created 4 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/js_rti.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_rti.dart b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
index 497666ff289767325966bbe25606c3709f195043..4ea0e5eb69c47bb56266ba8beb04cca5480dcbb4 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_rti.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
@@ -228,23 +228,21 @@ Type getRuntimeType(var object) {
* possible values for [substitution].
*/
substitute(var substitution, var arguments) {
- assert(substitution == null ||
- isJsFunction(substitution));
+ if (substitution == null) return arguments;
+ assert(isJsFunction(substitution));
assert(arguments == null || isJsArray(arguments));
+ substitution = invoke(substitution, arguments);
+ if (substitution == null) return substitution;
Siggi Cherem (dart-lang) 2016/09/10 00:50:40 nit, feel free to ignore: consider just retuning `
+ if (isJsArray(substitution)) {
+ // Substitutions are generated too late to mark Array as used, so use a
+ // tautological JS 'cast' to mark Array as used. This is needed only in
+ // some tiny tests where the substition is the only thing that creates an
+ // Array.
+ return JS('JSArray', '#', substitution);
+ }
if (isJsFunction(substitution)) {
- substitution = invoke(substitution, arguments);
- if (substitution == null) return substitution;
- if (isJsArray(substitution)) {
- // Substitutions are generated too late to mark Array as used, so use a
- // tautological JS 'cast' to mark Array as used. This is needed only in
- // some tiny tests where the substition is the only thing that creates an
- // Array.
- return JS('JSArray', '#', substitution);
- }
- if (isJsFunction(substitution)) {
- // TODO(johnniwinther): Check if this is still needed.
- return invoke(substitution, arguments);
- }
+ // TODO(johnniwinther): Check if this is still needed.
+ return invoke(substitution, arguments);
}
return arguments;
}
@@ -467,12 +465,12 @@ bool isSubtype(var s, var t) {
// Get the necessary substitution of the type arguments, if there is one.
var substitution;
if (isNotIdentical(typeOfT, typeOfS)) {
- if (!builtinIsSubtype(typeOfS, runtimeTypeToString(typeOfT))) {
+ String typeOfTString = runtimeTypeToString(typeOfT);
+ if (!builtinIsSubtype(typeOfS, typeOfTString)) {
return false;
}
var typeOfSPrototype = JS('', '#.prototype', typeOfS);
- var field = '${JS_GET_NAME(JsGetName.OPERATOR_AS_PREFIX)}'
- '${runtimeTypeToString(typeOfT)}';
+ var field = '${JS_GET_NAME(JsGetName.OPERATOR_AS_PREFIX)}${typeOfTString}';
substitution = getField(typeOfSPrototype, field);
}
// The class of [s] is a subclass of the class of [t]. If [s] has no type
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698