Replace LinkedList by a more performant collection

This is a semi-automatic change.
See https://errorprone.info/bugpattern/JdkObsolete for the rationale.

Test: make
Bug: 221046110
Change-Id: I631486d3707e56a56e3123d04c0fdb6af3d85715
This commit is contained in:
Nikolas Havrikov
2022-02-23 16:19:58 +01:00
parent dbb7976008
commit f194d4a996
4 changed files with 9 additions and 10 deletions

View File

@@ -25,8 +25,8 @@ import com.android.internal.util.TraceBuffer;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.function.Consumer;
@@ -50,7 +50,7 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
private final File mTraceFile;
private final ProtoTraceParams<P, S, T, R> mParams;
private Choreographer mChoreographer;
private final Queue<T> mPool = new LinkedList<>();
private final Queue<T> mPool = new ArrayDeque<>();
private final ArrayList<ProtoTraceable<R>> mTraceables = new ArrayList<>();
private final ArrayList<ProtoTraceable<R>> mTmpTraceables = new ArrayList<>();

View File

@@ -18,9 +18,9 @@ package com.android.systemui.classifier;
import android.view.MotionEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -33,13 +33,13 @@ import java.util.ListIterator;
*/
public class TimeLimitedMotionEventBuffer implements List<MotionEvent> {
private final LinkedList<MotionEvent> mMotionEvents;
private final List<MotionEvent> mMotionEvents;
private final long mMaxAgeMs;
public TimeLimitedMotionEventBuffer(long maxAgeMs) {
super();
mMaxAgeMs = maxAgeMs;
mMotionEvents = new LinkedList<>();
mMotionEvents = new ArrayList<>();
}
private void ejectOldEvents() {
@@ -47,7 +47,7 @@ public class TimeLimitedMotionEventBuffer implements List<MotionEvent> {
return;
}
Iterator<MotionEvent> iter = listIterator();
long mostRecentMs = mMotionEvents.getLast().getEventTime();
long mostRecentMs = mMotionEvents.get(mMotionEvents.size() - 1).getEventTime();
while (iter.hasNext()) {
MotionEvent ev = iter.next();
if (mostRecentMs - ev.getEventTime() > mMaxAgeMs) {

View File

@@ -35,8 +35,8 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -72,7 +72,7 @@ public class KeyguardIndicationRotateTextViewController extends
@Nullable private ShowNextIndication mShowNextIndicationRunnable;
// List of indication types to show. The next indication to show is always at index 0
private final List<Integer> mIndicationQueue = new LinkedList<>();
private final List<Integer> mIndicationQueue = new ArrayList<>();
private @IndicationType int mCurrIndicationType = INDICATION_TYPE_NONE;
private CharSequence mCurrMessage;
private long mLastIndicationSwitch;

View File

@@ -57,7 +57,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
@@ -126,7 +125,7 @@ public class TvOngoingPrivacyChip extends CoreStartable implements PrivacyItemCo
private final Runnable mCollapseRunnable = this::collapseChip;
private final Runnable mAccessibilityRunnable = this::makeAccessibilityAnnouncement;
private final List<PrivacyItem> mItemsBeforeLastAnnouncement = new LinkedList<>();
private final List<PrivacyItem> mItemsBeforeLastAnnouncement = new ArrayList<>();
@State
private int mState = STATE_NOT_SHOWN;