summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2019-03-19 20:42:10 -0700
committerMasaya Suzuki <masayasuzuki@google.com>2019-03-20 15:52:14 -0700
commit47e37b0fa4c91aa0fe3edfc298e93ddeed4c5473 (patch)
tree4ee15780ffd96c640c59df0bf615f8ef4a7499e2 /org.eclipse.jgit.test/tst/org
parent40e74f8a1a8acdea1ce62b8fd841989d781b84bc (diff)
downloadjgit-47e37b0fa4c91aa0fe3edfc298e93ddeed4c5473.tar.gz
jgit-47e37b0fa4c91aa0fe3edfc298e93ddeed4c5473.zip
Use RefMap instead of HashMap
HashMap<String, Ref> has a memory overhead for refs. Use RefMap. Change-Id: I3fb4616135dacf687cc3bc2b473effc66ccef5e6 Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
index d124d7365c..9981bd6514 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
@@ -128,6 +128,41 @@ public class RefListTest {
}
@Test
+ public void testBuilder_AddThenDedupe() {
+ RefList.Builder<Ref> builder = new RefList.Builder<>(1);
+ builder.add(REF_B);
+ builder.add(REF_A);
+ builder.add(REF_A);
+ builder.add(REF_B);
+ builder.add(REF_c);
+
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ RefList<Ref> list = builder.toRefList();
+
+ assertEquals(3, list.size());
+ assertSame(REF_A, list.get(0));
+ assertSame(REF_B, list.get(1));
+ assertSame(REF_c, list.get(2));
+ }
+
+ @Test
+ public void testBuilder_AddThenDedupe_Border() {
+ RefList.Builder<Ref> builder = new RefList.Builder<>(1);
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ RefList<Ref> list = builder.toRefList();
+ assertTrue(list.isEmpty());
+
+ builder = new RefList.Builder<>(1);
+ builder.add(REF_A);
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ list = builder.toRefList();
+ assertEquals(1, list.size());
+ }
+
+ @Test
public void testBuilder_AddAll() {
RefList.Builder<Ref> builder = new RefList.Builder<>(1);
Ref[] src = { REF_A, REF_B, REF_c, REF_A };