Replace iterable foreach loops with indexed for loops

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163343347
This commit is contained in:
eguven 2017-07-27 08:30:25 -07:00 committed by Oliver Woodman
parent ad5ca0812d
commit c3d7ccc3cb
3 changed files with 11 additions and 12 deletions

View File

@ -186,8 +186,8 @@ public final class DynamicConcatenatingMediaSource implements MediaSource, ExoPl
@Override @Override
public void maybeThrowSourceInfoRefreshError() throws IOException { public void maybeThrowSourceInfoRefreshError() throws IOException {
for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { for (int i = 0; i < mediaSourceHolders.size(); i++) {
mediaSourceHolder.mediaSource.maybeThrowSourceInfoRefreshError(); mediaSourceHolders.get(i).mediaSource.maybeThrowSourceInfoRefreshError();
} }
} }
@ -221,8 +221,8 @@ public final class DynamicConcatenatingMediaSource implements MediaSource, ExoPl
@Override @Override
public void releaseSource() { public void releaseSource() {
for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { for (int i = 0; i < mediaSourceHolders.size(); i++) {
mediaSourceHolder.mediaSource.releaseSource(); mediaSourceHolders.get(i).mediaSource.releaseSource();
} }
} }

View File

@ -34,9 +34,9 @@ import java.io.OutputStream;
import java.security.InvalidAlgorithmParameterException; import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import javax.crypto.Cipher; import javax.crypto.Cipher;
@ -176,14 +176,14 @@ import javax.crypto.spec.SecretKeySpec;
/** Removes empty {@link CachedContent} instances from index. */ /** Removes empty {@link CachedContent} instances from index. */
public void removeEmpty() { public void removeEmpty() {
LinkedList<String> cachedContentToBeRemoved = new LinkedList<>(); ArrayList<String> cachedContentToBeRemoved = new ArrayList<>();
for (CachedContent cachedContent : keyToContent.values()) { for (CachedContent cachedContent : keyToContent.values()) {
if (cachedContent.isEmpty()) { if (cachedContent.isEmpty()) {
cachedContentToBeRemoved.add(cachedContent.key); cachedContentToBeRemoved.add(cachedContent.key);
} }
} }
for (String key : cachedContentToBeRemoved) { for (int i = 0; i < cachedContentToBeRemoved.size(); i++) {
removeEmpty(key); removeEmpty(cachedContentToBeRemoved.get(i));
} }
} }

View File

@ -22,7 +22,6 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.NavigableSet; import java.util.NavigableSet;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
@ -308,7 +307,7 @@ public final class SimpleCache implements Cache {
* no longer exist. * no longer exist.
*/ */
private void removeStaleSpansAndCachedContents() throws CacheException { private void removeStaleSpansAndCachedContents() throws CacheException {
LinkedList<CacheSpan> spansToBeRemoved = new LinkedList<>(); ArrayList<CacheSpan> spansToBeRemoved = new ArrayList<>();
for (CachedContent cachedContent : index.getAll()) { for (CachedContent cachedContent : index.getAll()) {
for (CacheSpan span : cachedContent.getSpans()) { for (CacheSpan span : cachedContent.getSpans()) {
if (!span.file.exists()) { if (!span.file.exists()) {
@ -316,9 +315,9 @@ public final class SimpleCache implements Cache {
} }
} }
} }
for (CacheSpan span : spansToBeRemoved) { for (int i = 0; i < spansToBeRemoved.size(); i++) {
// Remove span but not CachedContent to prevent multiple index.store() calls. // Remove span but not CachedContent to prevent multiple index.store() calls.
removeSpan(span, false); removeSpan(spansToBeRemoved.get(i), false);
} }
index.removeEmpty(); index.removeEmpty();
index.store(); index.store();