diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-08-19 11:43:39 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-08-19 11:43:39 -0700 |
commit | d0043e5d31e8b923884147ca1bab6e5416497323 (patch) | |
tree | bfb41c0eaf4d6ae412d13b939e2e642e454e6ea5 /org.eclipse.jgit.junit | |
parent | b7388637d80b1a73bf617a3656caea80f5ac682f (diff) | |
download | jgit-d0043e5d31e8b923884147ca1bab6e5416497323.tar.gz 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')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 4 | ||||
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java | 2 |
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())); } /** |