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;
|
locator<PatcherViewModel>().selectedPatches;
|
||||||
PatchedApplication? selectedApp = locator<PatcherViewModel>().selectedApp;
|
PatchedApplication? selectedApp = locator<PatcherViewModel>().selectedApp;
|
||||||
String? patchesVersion = '';
|
String? patchesVersion = '';
|
||||||
|
|
||||||
|
Set<String> savedPatchNames = {};
|
||||||
|
|
||||||
bool isDefaultPatchesRepo() {
|
bool isDefaultPatchesRepo() {
|
||||||
return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches';
|
return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches';
|
||||||
}
|
}
|
||||||
@ -48,6 +51,9 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
|||||||
});
|
});
|
||||||
currentSelection.clear();
|
currentSelection.clear();
|
||||||
currentSelection.addAll(selectedPatches);
|
currentSelection.addAll(selectedPatches);
|
||||||
|
|
||||||
|
savedPatchNames = _managerAPI.getSavedPatches(selectedApp!.packageName).map((p) => p.name).toSet();
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,13 +287,10 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isPatchNew(Patch patch) {
|
bool isPatchNew(Patch patch) {
|
||||||
final List<Patch> savedPatches =
|
if (savedPatchNames.isEmpty) {
|
||||||
_managerAPI.getSavedPatches(selectedApp!.packageName);
|
|
||||||
if (savedPatches.isEmpty) {
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return !savedPatches
|
return !savedPatchNames.contains(patch.name);
|
||||||
.any((p) => p.getSimpleName() == patch.getSimpleName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user