From d55eb351061de32f208a924ce076bb8903e9c379 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Thu, 3 Nov 2011 12:57:58 -0700 Subject: [PATCH] Expose the reverse index size in the DfsPackDescription This is analogous to the getPackSize() and getIndexSize() methods. Change-Id: I207c0c93f9145826d84b3610eb4319fca074ee0d --- .../org/eclipse/jgit/storage/dfs/DfsPackDescription.java | 7 +++++++ .../src/org/eclipse/jgit/storage/dfs/DfsPackFile.java | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java index 9e1e597af..1bd5a7827 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java @@ -164,6 +164,13 @@ public class DfsPackDescription implements Comparable { return this; } + /** + * @return size of the reverse index, in bytes. + */ + public int getReverseIndexSize() { + return (int) Math.min(objectCount * 8, Integer.MAX_VALUE); + } + /** @return number of objects in the pack. */ public long getObjectCount() { return objectCount; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java index 573e8e706..7afcea226 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java @@ -265,11 +265,9 @@ public final class DfsPackFile { return revidx; } - PackIndex fwdidx = idx(ctx); - PackReverseIndex revidx = new PackReverseIndex(fwdidx); - long objCnt = fwdidx.getObjectCount(); - int sz = (int) Math.min(objCnt * 8, Integer.MAX_VALUE); - reverseIndex = cache.put(key, POS_REVERSE_INDEX, sz, revidx); + PackReverseIndex revidx = new PackReverseIndex(idx(ctx)); + reverseIndex = cache.put(key, POS_REVERSE_INDEX, + packDesc.getReverseIndexSize(), revidx); return revidx; } }