mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +00:00
improve performance of helper method
- compare integers instead of Strings - cache results per day
This commit is contained in:
parent
a63f0d67bd
commit
c8328fa347
1 changed files with 10 additions and 4 deletions
|
|
@ -233,8 +233,12 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Map<String, List<Manga>> _dayCache = {};
|
||||||
|
|
||||||
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
||||||
return data.where((e) {
|
final key = "${day.year}-${day.month}-${day.day}";
|
||||||
|
if (_dayCache.containsKey(key)) return _dayCache[key]!;
|
||||||
|
final result = data.where((e) {
|
||||||
final lastChapter = e.chapters
|
final lastChapter = e.chapters
|
||||||
.filter()
|
.filter()
|
||||||
.sortByDateUploadDesc()
|
.sortByDateUploadDesc()
|
||||||
|
|
@ -244,10 +248,12 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||||
? DateTime.fromMillisecondsSinceEpoch(lastDate)
|
? DateTime.fromMillisecondsSinceEpoch(lastDate)
|
||||||
: DateTime.now();
|
: DateTime.now();
|
||||||
final temp = start.add(Duration(days: e.smartUpdateDays!));
|
final temp = start.add(Duration(days: e.smartUpdateDays!));
|
||||||
final predictedDay = "${temp.year}-${temp.month}-${temp.day}";
|
return temp.year == day.year &&
|
||||||
final selectedDay = "${day.year}-${day.month}-${day.day}";
|
temp.month == day.month &&
|
||||||
return predictedDay == selectedDay;
|
temp.day == day.day;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
_dayCache[key] = result;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Manga> _getEntriesForRange(
|
List<Manga> _getEntriesForRange(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue