if chains → switch expressions (#147793)
Previous "if-chains" pull requests: - https://github.com/flutter/flutter/pull/144905 - https://github.com/flutter/flutter/pull/144977 - https://github.com/flutter/flutter/pull/145194 - https://github.com/flutter/flutter/pull/146293 - https://github.com/flutter/flutter/pull/147472 <br> I think this one should be enough to wrap things up! fixes https://github.com/flutter/flutter/issues/144903 --------- Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This commit is contained in:
@@ -118,19 +118,12 @@ List<TimelineEvent>? _parseEvents(Map<String, dynamic> json) {
|
||||
.toList();
|
||||
|
||||
timelineEvents.sort((TimelineEvent e1, TimelineEvent e2) {
|
||||
final int? ts1 = e1.timestampMicros;
|
||||
final int? ts2 = e2.timestampMicros;
|
||||
if (ts1 == null) {
|
||||
if (ts2 == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (ts2 == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return ts1.compareTo(ts2);
|
||||
}
|
||||
return switch ((e1.timestampMicros, e2.timestampMicros)) {
|
||||
(null, null) => 0,
|
||||
(_, null) => 1,
|
||||
(null, _) => -1,
|
||||
(final int ts1, final int ts2) => ts1.compareTo(ts2),
|
||||
};
|
||||
});
|
||||
|
||||
return timelineEvents;
|
||||
|
||||
Reference in New Issue
Block a user