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

Unified Diff: runtime/bin/builtin.dart

Issue 543713002: Reduce the number of Uris parsed in builtin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | runtime/bin/dartutils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 2dbc3e79eb8a03e46ea740b674026c4902bbd593..7ecc3344192a6f3b6f6f0aba9ce3f89306b04bce 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -172,10 +172,8 @@ String _filePathFromUri(String userUri) {
case '':
case 'file':
return uri.toFilePath();
- break;
case 'package':
return _filePathFromPackageUri(uri);
- break;
case 'http':
return uri.toString();
default:
@@ -282,27 +280,43 @@ void _asyncLoadError(uri, libraryUri, error) {
}
+// Create a Uri of 'userUri'. Is the input uri is a package uri, the package uri
Ivan Posva 2014/09/04 15:33:18 If the input uri ..., then the package ...
Anders Johnsen 2014/09/05 05:33:24 Done.
+// is resolved.
+Uri _createUri(String userUri) {
+ var uri = Uri.parse(userUri);
+ _logResolution('# Creating uri for: $uri');
+
+ switch (uri.scheme) {
+ case '':
+ case 'file':
+ case 'http':
+ return uri;
+ case 'package':
+ return Uri.parse(_filePathFromPackageUri(uri));
+ default:
+ // Only handling file, http, and package URIs
+ // in standalone binary.
+ _logResolution('# Unknown scheme (${uri.scheme}) in $uri.');
+ throw 'Not a known scheme: $uri';
+ }
+}
+
+
// Asynchronously loads script data through a http or file uri.
_loadDataAsync(int tag, String uri, String libraryUri) {
- var filePath;
- Uri sourceUri;
if (tag == null) {
uri = _resolveScriptUri(uri);
- sourceUri = Uri.parse(uri);
- filePath = _filePathFromUri(uri);
- } else {
- filePath = _filePathFromUri(uri);
- sourceUri = Uri.parse(filePath);
}
+ Uri resourceUri = _createUri(uri);
_numOutstandingLoadRequests++;
_logResolution("_loadDataAsync($uri), "
"${_numOutstandingLoadRequests} requests outstanding");
- if (sourceUri.scheme == 'http') {
- _httpGet(sourceUri, libraryUri, (data) {
+ if (resourceUri.scheme == 'http') {
+ _httpGet(resourceUri, libraryUri, (data) {
_loadScript(tag, uri, libraryUri, data);
});
} else {
- var sourceFile = new File(filePath);
+ var sourceFile = new File(resourceUri.toFilePath());
sourceFile.readAsBytes().then((data) {
_loadScript(tag, uri, libraryUri, data);
},
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698