You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GitBox <gi...@apache.org> on 2020/04/07 16:22:41 UTC

[GitHub] [tomcat] larsgrefer opened a new pull request #271: Use empty arrays for Collections.toArray()

larsgrefer opened a new pull request #271: Use empty arrays for Collections.toArray()
URL: https://github.com/apache/tomcat/pull/271
 
 
   There are two styles to convert a collection to an array:
   either using a pre-sized array (like `c.toArray(new String[c.size()])`)
   or using an empty array (like `c.toArray(new String[0])`).
   
   In older Java versions using pre-sized array was recommended,
   as the reflection call which is necessary to create an array of proper size was quite slow.
   However since late updates of OpenJDK 6 this call was intrinsified,
   making the performance of the empty array version the same and sometimes even better,
   compared to the pre-sized version.
   
   See also: https://shipilev.net/blog/2016/arrays-wisdom-ancients/

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org