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

Unified Diff: sdk/lib/_internal/pub/lib/src/solver/version_solver.dart

Issue 1113363004: Cache pubspecs when HostedSource.getVersions is called. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 7 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 | « sdk/lib/_internal/pub/lib/src/command/cache_add.dart ('k') | sdk/lib/_internal/pub/lib/src/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
diff --git a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
index 0a71f0093080fde15ab144837d58406074806c3a..7dbcc9b9cc349fd0b4e4775c1762280ff9a76396 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
@@ -139,7 +139,7 @@ class SolveResult {
class PubspecCache {
final SourceRegistry _sources;
- /// The already-requested cached version lists.
+ /// The already-requested cached pubspec lists.
final _versions = new Map<PackageRef, List<PackageId>>();
/// The errors from failed version list requests.
@@ -224,13 +224,20 @@ class PubspecCache {
var source = _sources[package.source];
return source.getVersions(package.name, package.description)
- .then((versions) {
+ .then((pubspecs) {
// Sort by priority so we try preferred versions first.
- versions.sort(_type == SolveType.DOWNGRADE ? Version.antiprioritize :
- Version.prioritize);
-
- var ids = versions.reversed.map(
- (version) => package.atVersion(version)).toList();
+ pubspecs.sort((pubspec1, pubspec2) {
+ return _type == SolveType.DOWNGRADE
+ ? Version.antiprioritize(pubspec1.version, pubspec2.version)
+ : Version.prioritize(pubspec1.version, pubspec2.version);
+ });
+
+ var ids = pubspecs.reversed.map((pubspec) {
+ var id = package.atVersion(pubspec.version);
+ // Eagerly cache the pubspec now since we have it.
+ _pubspecs[id] = pubspec;
+ return id;
+ }).toList();
_versions[package] = ids;
return ids;
}).catchError((error, trace) {
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/cache_add.dart ('k') | sdk/lib/_internal/pub/lib/src/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698