Cost of using repeated parameters
        Posted  
        
            by Palimondo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Palimondo
        
        
        
        Published on 2010-03-16T03:00:00Z
        Indexed on 
            2010/03/16
            5:06 UTC
        
        
        Read the original article
        Hit count: 457
        
I consider refactoring few method signatures that currently take parameter of type List or Set of concrete classes --List[Foo]-- to use repeated parameters instead: Foo*. This would allow me to use the same method name and overload it based on the parameter type. This was not possible using List or Set, because List[Foo] and List[Bar] have same type after erasure: List[Object]. 
In my case the refactored methods work fine with scala.Seq[Foo] that results from the repeated parameter. I would have to change all the invocations and add a sequence argument type annotation to all collection parameters: baz.doStuffWith(foos:_*).
Given that switching from collection parameter to repeated parameter is semantically equivalent, does this change have some performance impact that I should be aware of?
Is the answer same for scala 2.7._ and 2.8?
© Stack Overflow or respective owner