aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-03-18 09:07:25 -0700
committerShawn O. Pearce <spearce@spearce.org>2011-03-18 09:11:56 -0700
commit62fe7c7313e4e7a4339fe9df3a9dc2335461df29 (patch)
tree5c38b105842c4675351f8e98fa4631ae1c93fcda /org.eclipse.jgit.test/tst/org
parent48fb404a3f155805a67bdc18c7ca22d18df03be2 (diff)
downloadjgit-62fe7c7313e4e7a4339fe9df3a9dc2335461df29.tar.gz
jgit-62fe7c7313e4e7a4339fe9df3a9dc2335461df29.zip
BlockList: Micro-optimize appending from another BlockList
Simple variant of addAll() that knows how to copy large segments quickly using System.arraycopy() rather than looping through with an Iterator object. Change-Id: Icb50a8f87fe9180ea28b6920f473bb9e70c300f1 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java
index 7151af156a..8b042bd67c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java
@@ -282,6 +282,24 @@ public class BlockListTest {
}
@Test
+ public void testAddAllFromOtherList() {
+ BlockList<Integer> src = new BlockList<Integer>(4);
+ int cnt = BlockList.BLOCK_SIZE * 2;
+
+ for (int i = 0; i < cnt; i++)
+ src.add(Integer.valueOf(42 + i));
+ src.add(Integer.valueOf(1));
+
+ BlockList<Integer> dst = new BlockList<Integer>(4);
+ dst.add(Integer.valueOf(255));
+ dst.addAll(src);
+ assertEquals(cnt + 2, dst.size());
+ for (int i = 0; i < cnt; i++)
+ assertEquals(Integer.valueOf(42 + i), dst.get(i + 1));
+ assertEquals(Integer.valueOf(1), dst.get(dst.size() - 1));
+ }
+
+ @Test
public void testFastIterator() {
BlockList<Integer> list = new BlockList<Integer>(4);
int cnt = BlockList.BLOCK_SIZE * 3;