More like “why is .toVector
slower than .toList
here” as I don’t see other differences. Scala’s stdlib uses mutability for performance reasons. .toList
uses mutability to construct a List quickly (in linear time, with constant memory overhead). .toVector
probably also uses mutability but maybe in a less effective way.
1 Like