Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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)
downloadjgit-d0043e5d31e8b923884147ca1bab6e5416497323.tar.gz
jgit-d0043e5d31e8b923884147ca1bab6e5416497323.tar.xz
jgit-d0043e5d31e8b923884147ca1bab6e5416497323.zip
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 <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java4
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java2
2 files changed, 1 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
index 47956e5127..d28c7edb50 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
@@ -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/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index afe1c0bc63..858fe64a6d 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -586,7 +586,7 @@ public class TestRepository<R extends Repository> {
md.update(Constants.encodeASCII(bin.length));
md.update((byte) 0);
md.update(bin);
- Assert.assertEquals(id.copy(), ObjectId.fromRaw(md.digest()));
+ Assert.assertEquals(id, ObjectId.fromRaw(md.digest()));
}
/**

Back to the top