]> source.dussan.org Git - jgit.git/commitdiff
Do not update the ref hot bit when checking isIndexLoaded 62/18362/1
authorColby Ranger <cranger@google.com>
Wed, 13 Nov 2013 23:19:03 +0000 (15:19 -0800)
committerColby Ranger <cranger@google.com>
Wed, 13 Nov 2013 23:19:03 +0000 (15:19 -0800)
DfsPackFile.isIndexLoaded() uses the DfsBlockCache.Ref.get() method
to check if the index loaded. However, using the get() method marks
a hot bit in the cache, which can cause the index to never be unloaded
and seem hotter than it really is. Add a has() method which only
checks if the value is not null and does not update the hot bit.

Change-Id: I7e9ed216f6e273e8f5d79ae573973197654419b4

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java

index a8d797dff2f6d1fae687f1110f7a8c717fddf72f..748a4a38e0e562d769d8357a7a29ba6900fd95e7 100644 (file)
@@ -556,5 +556,9 @@ public final class DfsBlockCache {
                                hot = true;
                        return v;
                }
+
+               boolean has() {
+                       return value != null;
+               }
        }
 }
index 1c588d2c4e595c95ddfa608b5522773456ff2b9a..7c4776ea0673a1e6505e289a8c8e68ee16dbbc20 100644 (file)
@@ -191,7 +191,7 @@ public final class DfsPackFile {
         */
        public boolean isIndexLoaded() {
                DfsBlockCache.Ref<PackIndex> idxref = index;
-               return idxref != null && idxref.get() != null;
+               return idxref != null && idxref.has();
        }
 
        /** @return bytes cached in memory for this pack, excluding the index. */