mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
perf: Use hashset for fast comparison
This commit is contained in:
parent
7f26c5bd45
commit
1fad90441c
@ -25,6 +25,9 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
locator<PatcherViewModel>().selectedPatches;
|
||||
PatchedApplication? selectedApp = locator<PatcherViewModel>().selectedApp;
|
||||
String? patchesVersion = '';
|
||||
|
||||
Set<String> savedPatchNames = {};
|
||||
|
||||
bool isDefaultPatchesRepo() {
|
||||
return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches';
|
||||
}
|
||||
@ -48,6 +51,9 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
});
|
||||
currentSelection.clear();
|
||||
currentSelection.addAll(selectedPatches);
|
||||
|
||||
savedPatchNames = _managerAPI.getSavedPatches(selectedApp!.packageName).map((p) => p.name).toSet();
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@ -281,13 +287,10 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
bool isPatchNew(Patch patch) {
|
||||
final List<Patch> savedPatches =
|
||||
_managerAPI.getSavedPatches(selectedApp!.packageName);
|
||||
if (savedPatches.isEmpty) {
|
||||
if (savedPatchNames.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return !savedPatches
|
||||
.any((p) => p.getSimpleName() == patch.getSimpleName());
|
||||
return !savedPatchNames.contains(patch.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user