Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-08-06 08:11:26 -0400
committerJonathan Nieder2018-08-23 01:34:39 -0400
commit2fc00af44e5658cf34200ad20d777a75333a0564 (patch)
tree4176d6c478946dee29d54fac9d6eb2f91bdbb613 /org.eclipse.jgit.http.server/src
parent7058493fea6992c914a200b64f48b0b61f192ac0 (diff)
downloadjgit-2fc00af44e5658cf34200ad20d777a75333a0564.tar.gz
jgit-2fc00af44e5658cf34200ad20d777a75333a0564.tar.xz
jgit-2fc00af44e5658cf34200ad20d777a75333a0564.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: I80388532fb4b2b0663ee1fe8baa94f5df55c8442 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.http.server/src')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java2
2 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
index 195dff9613..75611eec95 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
@@ -77,7 +77,7 @@ abstract class SmartServiceInfoRefs implements Filter {
SmartServiceInfoRefs(String service, List<Filter> filters) {
this.svc = service;
- this.filters = filters.toArray(new Filter[filters.size()]);
+ this.filters = filters.toArray(new Filter[0]);
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java
index 18650eb95b..f16749775f 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java
@@ -98,7 +98,7 @@ abstract class ServletBinderImpl implements ServletBinder {
* @return the configured filters; zero-length array if none.
*/
protected Filter[] getFilters() {
- return filters.toArray(new Filter[filters.size()]);
+ return filters.toArray(new Filter[0]);
}
/** @return the pipeline that matches and executes this chain. */

Back to the top