Skip to content

Commit 67015b7

Browse files
kevmooCommit Queue
authored andcommitted
[dart2js:dump_info] put version and program info first...
...more consistent sorting of holdings (improves diffing) Change-Id: I2f2c418edea1f2dec6b8cc26e8058a5e3855ceb2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271820 Auto-Submit: Kevin Moore <kevmoo@google.com> Commit-Queue: Kevin Moore <kevmoo@google.com> Reviewed-by: Mark Zhou <markzipan@google.com>
1 parent fe087f2 commit 67015b7

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

pkg/dart2js_info/lib/json_info_codec.dart

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,30 @@ class AllInfoToJsonConverter extends Converter<AllInfo, Map>
415415
};
416416
}
417417

418-
Map visitDependencyInfo(DependencyInfo info) =>
419-
{'id': idFor(info.target).serializedId, 'mask': info.mask};
418+
Map visitDependencyInfo(DependencyInfo info) => {
419+
'id': idFor(info.target).serializedId,
420+
if (info.mask != null) 'mask': info.mask,
421+
};
420422

421423
Map _visitAllInfoHolding(AllInfo allInfo) {
422424
var map = SplayTreeMap<String, List>(compareNatural);
423425
void helper(CodeInfo info) {
424426
if (info.uses.isEmpty) return;
425-
map[idFor(info).serializedId] = info.uses
426-
.map(visitDependencyInfo)
427-
.toList()
428-
..sort((a, b) => a['id'].compareTo(b['id']));
427+
map[idFor(info).serializedId] =
428+
info.uses.map(visitDependencyInfo).toList()
429+
..sort((a, b) {
430+
final value = a['id'].compareTo(b['id']);
431+
if (value != 0) return value;
432+
final aMask = a['mask'] as String?;
433+
final bMask = b['mask'] as String?;
434+
if (aMask == null) {
435+
return bMask == null ? 0 : 1;
436+
}
437+
if (bMask == null) {
438+
return -1;
439+
}
440+
return aMask.compareTo(bMask);
441+
});
429442
}
430443

431444
allInfo.functions.forEach(helper);
@@ -447,14 +460,14 @@ class AllInfoToJsonConverter extends Converter<AllInfo, Map>
447460
var jsonHolding = _visitAllInfoHolding(info);
448461
var jsonDependencies = _visitAllInfoDependencies(info);
449462
return {
463+
'dump_version': isBackwardCompatible ? 5 : info.version,
464+
'dump_minor_version': isBackwardCompatible ? 1 : info.minorVersion,
465+
'program': info.program!.accept(this),
450466
'elements': elements,
451467
'holding': jsonHolding,
452468
'dependencies': jsonDependencies,
453469
'outputUnits': info.outputUnits.map((u) => u.accept(this)).toList(),
454-
'dump_version': isBackwardCompatible ? 5 : info.version,
455470
'deferredFiles': info.deferredFiles,
456-
'dump_minor_version': isBackwardCompatible ? 1 : info.minorVersion,
457-
'program': info.program!.accept(this)
458471
};
459472
}
460473

0 commit comments

Comments
 (0)