mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-11 13:46:17 +00:00
perf: Use hashset for fast comparison
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user