]> source.dussan.org Git - jgit.git/commitdiff
RepositoryCache: simplify code 16/85016/2
authorShawn Pearce <spearce@spearce.org>
Mon, 14 Nov 2016 22:52:23 +0000 (14:52 -0800)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 14 Nov 2016 23:51:55 +0000 (15:51 -0800)
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

org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

index 0a8bf62f95d6376b0ff552b3d822f12d3eb2beee..2f1a9e1cda38deb4034ed2bdcc4712cdf11515d8 100644 (file)
@@ -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);
                }
        }