Skip to content

Commit

Permalink
perf: improve performance of nextBusForCampus
Browse files Browse the repository at this point in the history
  • Loading branch information
kooWZ committed Jan 6, 2025
1 parent 8d214f3 commit 4291ac6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/feature/bus_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class BusFeature extends Feature {
BusScheduleItem? nextBusForCampus(Campus campus) {
// Split dual-direction bus with different start times into two single-direction buses to avoid confusion.
final List<BusScheduleItem> filteredBusList = _busList!
.where((element) => (element.start == campus || element.end == campus))
.expand(((element) => (element.direction == BusDirection.DUAL &&
!element.startTime!
.toExactTime()
Expand All @@ -141,7 +142,6 @@ class BusFeature extends Feature {
.copyWith(direction: BusDirection.FORWARD)
]
: [element]))
.where((element) => (element.start == campus || element.end == campus))
.toList();
// Get the next bus time
filteredBusList.sort();
Expand Down

0 comments on commit 4291ac6

Please sign in to comment.