summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-11-14 14:52:23 -0800
committerDavid Pursehouse <david.pursehouse@gmail.com>2016-11-14 15:51:55 -0800
commit3b2248c5cf5a4e6e725d9a12011ee8bd0ed18ccd (patch)
treec0890deffd8cb423ee7752bc0ca503ff1d02a23d
parentca4ef2d24b7761fd366f8725c263d34965b3e76f (diff)
downloadjgit-3b2248c5cf5a4e6e725d9a12011ee8bd0ed18ccd.tar.gz
jgit-3b2248c5cf5a4e6e725d9a12011ee8bd0ed18ccd.zip
RepositoryCache: simplify code
The type parameters can now be inferred when creating ConcurrentHashMap. A for loop over the keys of a ConcurrentHashMap doesn't need to use an Iterator<Map.Entry>; loop syntax handles this just fine over keySet(). Change-Id: I1f85bb81b77f7cd1caec77197f2f0bf78e4a82a1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java9
1 files changed, 3 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
index 0a8bf62f95..2f1a9e1cda 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
@@ -47,8 +47,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -225,7 +223,7 @@ public class RepositoryCache {
private volatile long expireAfter;
private RepositoryCache() {
- cacheMap = new ConcurrentHashMap<Key, Repository>();
+ cacheMap = new ConcurrentHashMap<>();
openLocks = new Lock[4];
for (int i = 0; i < openLocks.length; i++) {
openLocks[i] = new Lock();
@@ -314,9 +312,8 @@ public class RepositoryCache {
}
private void clearAll() {
- for (Iterator<Map.Entry<Key, Repository>> i = cacheMap
- .entrySet().iterator(); i.hasNext();) {
- unregisterAndCloseRepository(i.next().getKey());
+ for (Key k : cacheMap.keySet()) {
+ unregisterAndCloseRepository(k);
}
}