]> source.dussan.org Git - jgit.git/commitdiff
Expose the reverse index size in the DfsPackDescription 44/4544/3
authorDave Borowitz <dborowitz@google.com>
Thu, 3 Nov 2011 19:57:58 +0000 (12:57 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 4 Nov 2011 18:14:32 +0000 (11:14 -0700)
This is analogous to the getPackSize() and getIndexSize() methods.

Change-Id: I207c0c93f9145826d84b3610eb4319fca074ee0d

org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java

index 9e1e597afe03409eec372d24aaf83d630037ea17..1bd5a7827153b8c751effd67d74283c093d5e604 100644 (file)
@@ -164,6 +164,13 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
                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;
index 573e8e7067dcc34de9b40928316909aa55414f81..7afcea226df6832aa37a329321ca2334bafe5125 100644 (file)
@@ -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;
                }
        }