scala/scala — pull request #4202 by kanielc (2014-12-14 02:48:54+00:00)
Title: SI-9043 ArrayBuffer.insert and insertAll are very slow

insert and insertAll were slower than their java equivalents by factors
of 5 and 10 respectively.

Benchmark code was provided here:
https://gist.github.com/rklaehn/3e9290118fcf63d1feae

We are using a toList to the source Traversable
Then doing a length and a copy on that collection.

By using an array, we can make use of faster methods.
Managed to get the ratios down to 2 and 1.5 respectively.

In addition to this, I think we should consider breaking insert into 2
separate methods, one for a single item and one for a collection. The
varags version is very expensive when a single item is being inserted.

@phaller @axel22