diff options
author | Colby Ranger <cranger@google.com> | 2013-01-22 18:55:36 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-01-22 18:55:36 -0500 |
commit | aa2db859ea536f1e44c3ad641fb68fe4243d4737 (patch) | |
tree | a7517d13a8ec1cf5e943043b26b53bf3ca87ad70 | |
parent | 75ddf2a0f4f22f2b509b6077aae4c9f689a03665 (diff) | |
parent | 7fbd6588bed5e5dbed01ad2c85797d86596e5b71 (diff) | |
download | jgit-aa2db859ea536f1e44c3ad641fb68fe4243d4737.tar.gz jgit-aa2db859ea536f1e44c3ad641fb68fe4243d4737.zip |
Merge "Reduce memory held and speed up DfsGarbageCollector."
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java | 6 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java | 19 |
2 files changed, 18 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java index 21f01ad6b4..76fb521a62 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java @@ -61,6 +61,7 @@ import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.ObjectIdOwnerMap; import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.revwalk.RevWalk; @@ -332,10 +333,11 @@ public class DfsGarbageCollector { out.close(); } - final List<ObjectId> packedObjs = pw.getObjectList(); + final ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> packedObjs = pw + .getObjectSet(); newPackObj.add(new PackWriter.ObjectIdSet() { public boolean contains(AnyObjectId objectId) { - return 0 <= Collections.binarySearch(packedObjs, objectId); + return packedObjs.contains(objectId); } }); 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 b199d4feef..1cf1781289 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 @@ -519,8 +519,7 @@ public class PackWriter { } /** - * Returns the object ids in the pack file that was created by this writer, - * sorted by name. + * Returns the object ids in the pack file that was created by this writer. * * This method can only be invoked after * {@link #writePack(ProgressMonitor, ProgressMonitor, OutputStream)} has @@ -530,13 +529,23 @@ public class PackWriter { * @throws IOException * a cached pack cannot supply its object ids. */ - public List<ObjectId> getObjectList() throws IOException { + public ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> getObjectSet() + throws IOException { if (!cachedPacks.isEmpty()) throw new IOException( JGitText.get().cachedPacksPreventsListingObjects); - return Collections.unmodifiableList( - (List<? extends ObjectId>) sortByName()); + ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> objs = new ObjectIdOwnerMap< + ObjectIdOwnerMap.Entry>(); + for (BlockList<ObjectToPack> objList : objectsLists) { + if (objList != null) { + for (ObjectToPack otp : objList) + objs.add(new ObjectIdOwnerMap.Entry(otp) { + // A new entry that copies the ObjectId + }); + } + } + return objs; } /** |