Create List without creating intermediate Runnable array

This commit is contained in:
PerfectSlayer 2020-08-15 18:57:54 +02:00 committed by topjohnwu
parent 51c0c0edc5
commit 4019178cbe

View File

@ -19,7 +19,7 @@ package com.topjohnwu.superuser.internal;
import androidx.annotation.RestrictTo;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.Callable;
@ -77,7 +77,7 @@ public class SerialExecutorService extends AbstractExecutorService implements Ca
if (scheduleTask != null)
scheduleTask.cancel(true);
try {
return Arrays.asList(mTasks.toArray(new Runnable[]{}));
return new ArrayList<>(mTasks);
} finally {
mTasks.clear();
}