[dart2js] Fix dump-info tests by starting indexing at 0 instead of 1.

Also should cache on `serializedId` rather than just the `name`.

Change-Id: I16e095fea5f320d39d55374ce354b9302c3a1e75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346024
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Nate Biggs 2024-01-12 21:51:51 +00:00 committed by Commit Queue
parent d0e3d48172
commit df5a3d8678

View file

@ -375,8 +375,12 @@ class AllInfoToJsonConverter extends Converter<AllInfo, Map>
// longName isn't guaranteed to create unique serializedIds for some info
// constructs (such as closures), so we disambiguate here.
final count = idCounter.update(name, (v) => v + 1, ifAbsent: () => 0);
final id = Id(info.kind, count == 0 ? name : '$name%$count');
Id id = Id(info.kind, name);
final count =
idCounter.update(id.serializedId, (v) => v + 1, ifAbsent: () => 0);
if (count > 0) {
id = Id(info.kind, '$name%${count - 1}');
}
return ids[info] = id;
}