Skip to content

Commit 8bd0ca1

Browse files
committed
Refactor to add result types and avoid more temporary Lists
1 parent fba86e4 commit 8bd0ca1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ package tools.nsc
1515
package transform
1616

1717
import scala.annotation.tailrec
18-
1918
import symtab.Flags._
2019
import scala.collection.mutable
20+
import scala.collection.mutable.ListBuffer
2121
import scala.reflect.internal.util.ListOfNil
2222

2323
/*<export> */
@@ -250,12 +250,12 @@ abstract class UnCurry extends InfoTransform
250250
def transformArgs(pos: Position, fun: Symbol, args: List[Tree], params: List[Symbol]): List[Tree] = {
251251
val isJava = fun.isJavaDefined
252252

253-
def transformVarargs(varargsElemType: Type) = {
253+
def transformVarargs(varargsElemType: Type): List[Tree] = {
254254
def mkArrayValue(ts: List[Tree], elemtp: Type) =
255255
ArrayValue(TypeTree(elemtp), ts) setType arrayType(elemtp)
256256

257257
// when calling into scala varargs, make sure it's a sequence.
258-
def arrayToSequence(tree: Tree, elemtp: Type, copy: Boolean) = {
258+
def arrayToSequence(tree: Tree, elemtp: Type, copy: Boolean): Tree = {
259259
exitingUncurry {
260260
localTyper.typedPos(pos) {
261261
val pt = arrayType(elemtp)
@@ -274,7 +274,7 @@ abstract class UnCurry extends InfoTransform
274274
}
275275

276276
// when calling into java varargs, make sure it's an array - see bug #1360
277-
def sequenceToArray(tree: Tree) = {
277+
def sequenceToArray(tree: Tree): Tree = {
278278
val toArraySym = tree.tpe member nme.toArray
279279
assert(toArraySym != NoSymbol)
280280
def getClassTag(tp: Type): Tree = {
@@ -329,7 +329,10 @@ abstract class UnCurry extends InfoTransform
329329
}
330330
}
331331
}
332-
args.take(params.length - 1) :+ (suffix setType params.last.info)
332+
val args1 = ListBuffer[Tree]()
333+
args1 ++= args.iterator.take(params.length - 1)
334+
args1 += suffix setType params.last.info
335+
args1.toList
333336
}
334337

335338
val isVarargs = isVarArgsList(params)

0 commit comments

Comments
 (0)