Skip to content

Commit

Permalink
Optimized RequestTracker by using a Set instead of a List to track pe…
Browse files Browse the repository at this point in the history
…ndingRequests. This makes cancelling an incomplete request O(1) instead of O(n), by making remove()-by-value an O(1) function call.

PiperOrigin-RevId: 362418569
  • Loading branch information
yorickhenning authored and glide-copybara-robot committed Mar 12, 2021
1 parent 4ee9758 commit 627d04a
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import androidx.annotation.VisibleForTesting;
import com.bumptech.glide.request.Request;
import com.bumptech.glide.util.Util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.util.WeakHashMap;

Expand All @@ -31,8 +30,7 @@ public class RequestTracker {
// A set of requests that have not completed and are queued to be run again. We use this list to
// maintain hard references to these requests to ensure that they are not garbage collected
// before they start running or while they are paused. See #346.
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final List<Request> pendingRequests = new ArrayList<>();
private final Set<Request> pendingRequests = new HashSet<>();

private boolean isPaused;

Expand Down

0 comments on commit 627d04a

Please sign in to comment.