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

Unified Diff: pkg/compiler/lib/src/native/native.dart

Issue 1887313002: dart2js: Reduce calls to Uri.toString() (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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: pkg/compiler/lib/src/native/native.dart
diff --git a/pkg/compiler/lib/src/native/native.dart b/pkg/compiler/lib/src/native/native.dart
index 805196a05dce53f4075b8b8d52537146ba1d0038..9a8140183bde92999d6018aac913946a8fb3d058 100644
--- a/pkg/compiler/lib/src/native/native.dart
+++ b/pkg/compiler/lib/src/native/native.dart
@@ -13,24 +13,30 @@ export 'js.dart';
export 'scanner.dart';
export 'ssa.dart';
+const Iterable<String> _allowedDartSchemePaths = const <String>[
+ 'async',
+ 'html',
+ 'html_common',
+ 'indexed_db',
+ 'js',
+ 'svg',
+ '_native_typed_data',
+ 'web_audio',
+ 'web_gl',
+ 'web_sql'
+];
+
bool maybeEnableNative(Compiler compiler, LibraryElement library) {
- String libraryName = library.canonicalUri.toString();
- if (library.entryCompilationUnit.script.name
- .contains('sdk/tests/compiler/dart2js_native') ||
- library.entryCompilationUnit.script.name
- .contains('sdk/tests/compiler/dart2js_extra') ||
- libraryName == 'dart:async' ||
- libraryName == 'dart:html' ||
- libraryName == 'dart:html_common' ||
- libraryName == 'dart:indexed_db' ||
- libraryName == 'dart:js' ||
- libraryName == 'dart:svg' ||
- libraryName == 'dart:_native_typed_data' ||
- libraryName == 'dart:web_audio' ||
- libraryName == 'dart:web_gl' ||
- libraryName == 'dart:web_sql' ||
- compiler.options.allowNativeExtensions) {
- return true;
+ bool allowedTestLibrary() {
+ String scriptName = library.entryCompilationUnit.script.name;
+ return scriptName.contains('sdk/tests/compiler/dart2js_native') ||
+ scriptName.contains('sdk/tests/compiler/dart2js_extra');
+ }
+ bool allowedDartLibary() {
+ Uri uri = library.canonicalUri;
+ if (uri.scheme != 'dart') return false;
+ return _allowedDartSchemePaths.contains(uri.path);
}
- return false;
+
+ return allowedTestLibrary() || allowedDartLibary();
}
« 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