Skip to main content
diff options
authorShawn O. Pearce2010-08-19 18:43:39 +0000
committerShawn O. Pearce2010-08-19 18:43:39 +0000
commitd0043e5d31e8b923884147ca1bab6e5416497323 (patch)
treebfb41c0eaf4d6ae412d13b939e2e642e454e6ea5 /org.eclipse.jgit.junit/src
parentb7388637d80b1a73bf617a3656caea80f5ac682f (diff)
Remove unnecessary ObjectId.copy() calls
When RevObject overrode equals() to provide only reference equality we used to need to convert a RevObject into an ObjectId by copy() just to use standard Java tools like JUnit assertEquals(), or to use contains() or get() on standard java.util collection types. Now that we have removed this override and made ObjectId's equals() final (preventing any of this mess in the future), some copy() calls are unnecessary. Anytime the value is being used as an input to a lookup routine, or to an equals, we can avoid the copy(). However we still want to use copy() anytime we are given an ObjectId that may exist long-term, where we don't want the high cost of the additional storage from a RevCommit extension. So we can't remove all uses of copy(), just some of them. Change-Id: Ief275dace435c0ddfa362ac8e5d93558bc7e9fc3 Signed-off-by: Shawn O. Pearce <>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
2 files changed, 1 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
index 47956e5127..d28c7edb50 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
@@ -409,10 +409,6 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase {
protected static void assertEquals(AnyObjectId exp, AnyObjectId act) {
- if (exp != null)
- exp = exp.copy();
- if (act != null)
- act = act.copy();
Assert.assertEquals(exp, act);
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
index afe1c0bc63..858fe64a6d 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/
@@ -586,7 +586,7 @@ public class TestRepository<R extends Repository> {
md.update((byte) 0);
- Assert.assertEquals(id.copy(), ObjectId.fromRaw(md.digest()));
+ Assert.assertEquals(id, ObjectId.fromRaw(md.digest()));

Back to the top