From 4019178cbe8c22bb2c34796c53c9635e01f9efb8 Mon Sep 17 00:00:00 2001 From: PerfectSlayer Date: Sat, 15 Aug 2020 18:57:54 +0200 Subject: [PATCH] Create List without creating intermediate Runnable array --- .../topjohnwu/superuser/internal/SerialExecutorService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/topjohnwu/superuser/internal/SerialExecutorService.java b/core/src/main/java/com/topjohnwu/superuser/internal/SerialExecutorService.java index bfb16f2..894d70c 100644 --- a/core/src/main/java/com/topjohnwu/superuser/internal/SerialExecutorService.java +++ b/core/src/main/java/com/topjohnwu/superuser/internal/SerialExecutorService.java @@ -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(); }