diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-11-17 11:39:53 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-11-18 15:55:52 -0800 |
commit | 1421106d7627eb2c55b97b70d105b5ba1e26a2c0 (patch) | |
tree | 72155f2eef7a82b8798f46a2bfc4814baf4c96ca /org.eclipse.jgit | |
parent | 41a18d57bcaf3bb7eb4bcee5c1d53a222d07316b (diff) | |
download | jgit-1421106d7627eb2c55b97b70d105b5ba1e26a2c0.tar.gz jgit-1421106d7627eb2c55b97b70d105b5ba1e26a2c0.zip |
Use long for more object counts in PackWriter
Packs can contain up to 2^32-1 objects, which exceeds the range of a
Java int. Try harder to accept higher object counts in some cases by
using long more often when we are working with the object count value.
This is a trivial refactoring, we may have to make even more changes
to the object handling code to support more than 2^31-1 objects.
Change-Id: I8cd8146e97cd1c738ad5b48fa9e33804982167e7
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java index dc33e4ece7..2d4279ebc2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java @@ -799,7 +799,7 @@ public class PackWriter { } private void beginPhase(PackingPhase phase, ProgressMonitor monitor, - int cnt) { + long cnt) { state.phase = phase; String task; switch (phase) { @@ -822,7 +822,7 @@ public class PackWriter { throw new IllegalArgumentException( MessageFormat.format(JGitText.get().illegalPackingPhase, phase)); } - monitor.beginTask(task, cnt); + monitor.beginTask(task, (int) cnt); } private void endPhase(ProgressMonitor monitor) { @@ -888,7 +888,7 @@ public class PackWriter { long objCnt = getObjectCount(); stats.totalObjects = objCnt; - beginPhase(PackingPhase.WRITING, writeMonitor, (int) objCnt); + beginPhase(PackingPhase.WRITING, writeMonitor, objCnt); long writeStart = System.currentTimeMillis(); out.writeFileHeader(PACK_VERSION_GENERATED, objCnt); @@ -956,7 +956,7 @@ public class PackWriter { } private void searchForReuse(ProgressMonitor monitor) throws IOException { - int cnt = 0; + long cnt = 0; cnt += objectsLists[Constants.OBJ_COMMIT].size(); cnt += objectsLists[Constants.OBJ_TREE].size(); cnt += objectsLists[Constants.OBJ_BLOB].size(); @@ -967,7 +967,7 @@ public class PackWriter { if (cnt <= 4096) { // For small object counts, do everything as one list. - BlockList<ObjectToPack> tmp = new BlockList<ObjectToPack>(cnt); + BlockList<ObjectToPack> tmp = new BlockList<ObjectToPack>((int) cnt); tmp.addAll(objectsLists[Constants.OBJ_TAG]); tmp.addAll(objectsLists[Constants.OBJ_COMMIT]); tmp.addAll(objectsLists[Constants.OBJ_TREE]); |