You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "dk2k (via GitHub)" <gi...@apache.org> on 2023/04/12 16:31:31 UTC

[GitHub] [camel] dk2k opened a new pull request, #9855: Fix for code inspection "initial size for Collection.toArray() should be zero". Related to performance. PR for tooling

dk2k opened a new pull request, #9855:
URL: https://github.com/apache/camel/pull/9855

   Fix for code inspection "initial size for Collection.toArray() should be zero". Related to performance. PR for tooling
   
   #Justification
   
   Reports Collection.toArray() calls not in the preferred style, and suggests applying the preferred style.
   There are two styles to convert a collection to an array:
    
   A pre-sized array, for example, c.toArray(new String[c.size()])
   An empty array, for example, c.toArray(new String[0])
    
   In older Java versions, using a pre-sized array was recommended, as the reflection call 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. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray calls. This may result in extra nulls at the end of the array if the collection was concurrently shrunk during the operation.


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #9855: Fix for code inspection "initial size for Collection.toArray() should be zero". Related to performance. PR for tooling

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9855:
URL: https://github.com/apache/camel/pull/9855#issuecomment-1505677674

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus merged pull request #9855: Fix for code inspection "initial size for Collection.toArray() should be zero". Related to performance. PR for tooling

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #9855:
URL: https://github.com/apache/camel/pull/9855


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org