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

Unified Diff: lib/src/packages_io_impl.dart

Issue 2041103005: Cache packageName to base Uri mapping. (Closed) Base URL: https://github.com/dart-lang/package_config@master
Patch Set: Prepare for publishing. Created 4 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
« .gitignore ('K') | « .gitignore ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/packages_io_impl.dart
diff --git a/lib/src/packages_io_impl.dart b/lib/src/packages_io_impl.dart
index db39bdb58c124fe8f6499afd63552c77068523cc..0e9474639420d7552a6f0d524cfd05f71b161121 100644
--- a/lib/src/packages_io_impl.dart
+++ b/lib/src/packages_io_impl.dart
@@ -14,10 +14,15 @@ import "packages_impl.dart";
/// A [Packages] implementation based on a local directory.
class FilePackagesDirectoryPackages extends PackagesBase {
final Directory _packageDir;
+ final Map<String, Uri> _packageToBaseUriMap = <String, Uri>{};
+
FilePackagesDirectoryPackages(this._packageDir);
- Uri getBase(String packageName) =>
- new Uri.file(path.join(_packageDir.path, packageName, '.'));
+ Uri getBase(String packageName) {
+ return _packageToBaseUriMap.putIfAbsent(packageName, () {
+ return new Uri.file(path.join(_packageDir.path, packageName, '.'));
+ });
+ }
Iterable<String> _listPackageNames() {
return _packageDir
« .gitignore ('K') | « .gitignore ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698