Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-08-06 08:10:12 -0400
committerThomas Wolf2018-08-13 12:35:35 -0400
commit7e54c44063ed9769a9d3c443799c52d4b2989cfd (patch)
treef860a4245b256b885b031173130fea59852fc127 /org.eclipse.egit.ui.test/src/org
parentdcc38081a23dedcc855b0abfa6f14253b93a5626 (diff)
downloadegit-7e54c44063ed9769a9d3c443799c52d4b2989cfd.tar.gz
egit-7e54c44063ed9769a9d3c443799c52d4b2989cfd.tar.xz
egit-7e54c44063ed9769a9d3c443799c52d4b2989cfd.zip
refactor: simplify collection.toArray()
On recent VMs, collection.toArray(new T[0]) is faster than collection.toArray(new T[collection.size()]). Since it is also more readable, it should now be the preferred way of collection to array conversion. https://shipilev.net/blog/2016/arrays-wisdom-ancients/ Change-Id: If0c3202aa3ebb2d4e4ea68da8fe431cd8f363826 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java2
2 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index a1a698d7a..02bb84488 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -572,7 +572,7 @@ public class TestUtil {
if (project.equals(name))
items.add(item);
}
- return items.isEmpty() ? null : items.toArray(new SWTBotTreeItem[items.size()]);
+ return items.isEmpty() ? null : items.toArray(new SWTBotTreeItem[0]);
}
/**
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
index 0a9b90a8f..9a51d6397 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
@@ -95,7 +95,7 @@ public class MockLogicalResourceMapping extends ResourceMapping {
"Exception while computing logical model", e));
}
final IResource[] resourceArray = result
- .toArray(new IResource[result.size()]);
+ .toArray(new IResource[0]);
return new ResourceTraversal[] { new ResourceTraversal(resourceArray,
IResource.DEPTH_ONE, IResource.NONE), };
}

Back to the top