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.core.test/src
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.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/SampleResourceMapping.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java4
5 files changed, 6 insertions, 6 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
index 9c602c80b..a66dae237 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
@@ -157,7 +157,7 @@ public abstract class ModelTestCase extends GitTestCase {
}
} while (includedResources.addAll(newResources));
ResourceMapping[] mappings = allMappings
- .toArray(new ResourceMapping[allMappings.size()]);
+ .toArray(new ResourceMapping[0]);
GitSynchronizeData gsd = new GitSynchronizeData(repository, srcRev,
dstRev, true, includedResources);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/SampleResourceMapping.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/SampleResourceMapping.java
index b00771fdb..1fe9a8e0f 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/SampleResourceMapping.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/SampleResourceMapping.java
@@ -58,7 +58,7 @@ public class SampleResourceMapping extends ResourceMapping {
}
}
final IResource[] resourceArray = sampleSiblings
- .toArray(new IResource[sampleSiblings.size()]);
+ .toArray(new IResource[0]);
return new ResourceTraversal[] { new ResourceTraversal(
resourceArray, IResource.DEPTH_ONE, IResource.NONE), };
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
index 0ff0f3b3f..e3a396821 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
@@ -242,7 +242,7 @@ public class CommitOperationTest extends GitTestCase {
ArrayList<String> result = new ArrayList<String>();
for (IFile file:files)
result.add(file.getProjectRelativePath().toString());
- return result.toArray(new String[result.size()]);
+ return result.toArray(new String[0]);
}
@Test
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
index e1296307c..2361b57b5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
@@ -135,7 +135,7 @@ public class PushOperationTest extends DualRepositoryTestCase {
IFile newFile = testUtils.addFileToProject(proj, "folder2/file2.txt",
"New file");
files.add(newFile);
- IFile[] fileArr = files.toArray(new IFile[files.size()]);
+ IFile[] fileArr = files.toArray(new IFile[0]);
AddToIndexOperation trop = new AddToIndexOperation(files);
trop.execute(null);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
index 36c1b9769..57712b857 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
@@ -81,7 +81,7 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
}
});
- IFile[] fileArr = files.toArray(new IFile[files.size()]);
+ IFile[] fileArr = files.toArray(new IFile[0]);
assertTrackedState(fileArr, false);
@@ -127,7 +127,7 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
}
});
- IFile[] fileArr = files.toArray(new IFile[files.size()]);
+ IFile[] fileArr = files.toArray(new IFile[0]);
assertTrackedState(fileArr, false);

Back to the top