From f3b80f1a7417591eb0ad7fa2b212a0588f987441 Mon Sep 17 00:00:00 2001 From: Colby Ranger Date: Wed, 13 Nov 2013 15:19:03 -0800 Subject: [PATCH] Do not update the ref hot bit when checking isIndexLoaded 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/internal/storage/dfs/DfsBlockCache.java | 4 ++++ .../org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java index a8d797dff..748a4a38e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java @@ -556,5 +556,9 @@ public final class DfsBlockCache { hot = true; return v; } + + boolean has() { + return value != null; + } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java index 1c588d2c4..7c4776ea0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java @@ -191,7 +191,7 @@ public final class DfsPackFile { */ public boolean isIndexLoaded() { DfsBlockCache.Ref idxref = index; - return idxref != null && idxref.get() != null; + return idxref != null && idxref.has(); } /** @return bytes cached in memory for this pack, excluding the index. */