Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26d5225a authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] improve the performance of recomputeComponentVisibility

We don't need to snapshot each individual elements of the ArraySet.
It's more efficient to use "new WatchedArrayset" / "new ArraySet"
instead of snapshot(). The former uses a single "arrayCopy" wherease the
latter uses multiple "append".

BUG: 315494540
Test: perf test

Change-Id: I27fc026605af6bbabb21027a21e226674efb91aa
parent 34660c5e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1031,12 +1031,12 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
    private void recomputeComponentVisibility(
            ArrayMap<String, ? extends PackageStateInternal> existingSettings) {
        final WatchedArraySet<String> protectedBroadcasts;
        final WatchedArraySet<Integer> forceQueryable;
        final ArraySet<Integer> forceQueryable;
        synchronized (mProtectedBroadcastsLock) {
            protectedBroadcasts = mProtectedBroadcasts.snapshot();
            protectedBroadcasts = new WatchedArraySet<String>(mProtectedBroadcasts);
        }
        synchronized (mForceQueryableLock) {
            forceQueryable = mForceQueryable.snapshot();
            forceQueryable = new ArraySet<Integer>(mForceQueryable.untrackedStorage());
        }
        final ParallelComputeComponentVisibility computer = new ParallelComputeComponentVisibility(
                existingSettings, forceQueryable, protectedBroadcasts);
+2 −2
Original line number Diff line number Diff line
@@ -198,12 +198,12 @@ final class AppsFilterUtils {
        private static final int MAX_THREADS = 4;

        private final ArrayMap<String, ? extends PackageStateInternal> mExistingSettings;
        private final WatchedArraySet<Integer> mForceQueryable;
        private final ArraySet<Integer> mForceQueryable;
        private final WatchedArraySet<String> mProtectedBroadcasts;

        ParallelComputeComponentVisibility(
                @NonNull ArrayMap<String, ? extends PackageStateInternal> existingSettings,
                @NonNull WatchedArraySet<Integer> forceQueryable,
                @NonNull ArraySet<Integer> forceQueryable,
                @NonNull WatchedArraySet<String> protectedBroadcasts) {
            mExistingSettings = existingSettings;
            mForceQueryable = forceQueryable;