From 52e7fdc7efaa4ecfd68f71a51375e1870cc78dcc Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 5 Jan 2012 23:33:17 -0800 Subject: Misc optimizations with zip. --- src/compiler/scala/reflect/internal/Types.scala | 2 +- src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 3 +-- src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 371fb8d585..4e842c05da 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -5687,7 +5687,7 @@ trait Types extends api.Types { self: SymbolTable => val padded = sorted map (_._2.padTo(maxSeqLength, NoType)) val transposed = padded.transpose - val columns: List[Column[List[Type]]] = sorted.zipWithIndex map { + val columns: List[Column[List[Type]]] = mapWithIndex(sorted) { case ((k, v), idx) => Column(str(k), (xs: List[Type]) => str(xs(idx)), true) } diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 4a104857db..4012d08e42 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1711,8 +1711,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { private def makeArguments(fun: Symbol, vparams: List[Symbol]): List[Tree] = ( //! TODO: make sure the param types are seen from the right prefix - for ((tp, arg) <- fun.info.paramTypes zip vparams) yield - gen.maybeMkAsInstanceOf(Ident(arg), tp, arg.tpe) + map2(fun.info.paramTypes, vparams)((tp, arg) => gen.maybeMkAsInstanceOf(Ident(arg), tp, arg.tpe)) ) private def findSpec(tp: Type): Type = tp match { case TypeRef(pre, sym, _ :: _) => specializedType(tp) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index a6c2f75d5e..fa4664b34f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -924,9 +924,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } def validateVarianceArgs(tps: List[Type], variance: Int, tparams: List[Symbol]) { - (tps zip tparams) foreach { - case (tp, tparam) => validateVariance(tp, variance * tparam.variance) - } + foreach2(tps, tparams)((tp, tparam) => validateVariance(tp, variance * tparam.variance)) } validateVariance(base.info, CoVariance) -- cgit v1.2.3