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

Unified Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 359833002: Observatory: Lexicaly sort all kinds of lists (imports, libraries, classes, functions, fields). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
« 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: runtime/bin/vmservice/client/lib/src/service/object.dart
diff --git a/runtime/bin/vmservice/client/lib/src/service/object.dart b/runtime/bin/vmservice/client/lib/src/service/object.dart
index 6ab70cef7f799bb4dc0e9edf1cc50c896f45bb9f..127b517b5a17db7267d9118fa230e81626eb9fd3 100644
--- a/runtime/bin/vmservice/client/lib/src/service/object.dart
+++ b/runtime/bin/vmservice/client/lib/src/service/object.dart
@@ -7,6 +7,21 @@ part of service;
/// A [ServiceObject] is an object known to the VM service and is tied
/// to an owning [Isolate].
abstract class ServiceObject extends Observable {
+ static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
+ return o1.name.compareTo(o2.name);
+ }
+
+ List unifyByName(List list) {
+ list.sort(LexicalSortName);
+ return list.fold([], (newList, e) {
+ if (!newList.isEmpty && newList.last.name == e.name){
+ return newList;
+ }
+ newList.add(e);
+ return newList;
+ });
+ }
+
/// The owner of this [ServiceObject]. This can be an [Isolate], a
/// [VM], or null.
@reflectable ServiceObjectOwner get owner => _owner;
@@ -783,10 +798,8 @@ class Isolate extends ServiceObjectOwner with Coverage {
error = map['error'];
libraries.clear();
- for (var lib in map['libraries']) {
- libraries.add(lib);
- }
- libraries.sort((a,b) => a.name.compareTo(b.name));
+ libraries.addAll(map['libraries']);
+ libraries.sort(ServiceObject.LexicalSortName);
}
Future<TagProfile> updateTagProfile() {
@@ -994,15 +1007,18 @@ class Library extends ServiceObject with Coverage {
_loaded = true;
_upgradeCollection(map, isolate);
imports.clear();
- imports.addAll(map['imports']);
+ imports.addAll(unifyByName(map['imports']));
Cutch 2014/06/30 23:26:44 Why are there duplicate names?
Michael Lippautz (Google) 2014/06/30 23:42:10 The vm may return duplicates for libraries that al
scripts.clear();
- scripts.addAll(map['scripts']);
+ scripts.addAll(unifyByName(map['scripts']));
classes.clear();
classes.addAll(map['classes']);
+ classes.sort(ServiceObject.LexicalSortName);
variables.clear();
variables.addAll(map['variables']);
+ variables.sort(ServiceObject.LexicalSortName);
functions.clear();
functions.addAll(map['functions']);
+ functions.sort(ServiceObject.LexicalSortName);
}
}
@@ -1110,12 +1126,15 @@ class Class extends ServiceObject with Coverage {
subClasses.clear();
subClasses.addAll(map['subclasses']);
+ subClasses.sort(ServiceObject.LexicalSortName);
fields.clear();
fields.addAll(map['fields']);
+ fields.sort(ServiceObject.LexicalSortName);
functions.clear();
functions.addAll(map['functions']);
+ functions.sort(ServiceObject.LexicalSortName);
superClass = map['super'];
if (superClass != null) {
« 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