Skip to content

Commit

Permalink
Comment justifies instanceof in ConjureCollections#addAll (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdanfox authored Jul 3, 2018
1 parent 5243f5e commit 569b017
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private ConjureCollections() {
@SuppressWarnings("unchecked")
public static <T> void addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) {
if (elementsToAdd instanceof Collection) {
// This special-casing allows us to take advantage of the more performant
// ArrayList#addAll method which does a single System.arraycopy.
addTo.addAll((Collection<T>) elementsToAdd);
} else {
for (T element : elementsToAdd) {
Expand Down

0 comments on commit 569b017

Please sign in to comment.