Optimization of typedArgs.

Keep seeing what might be our single use of Tuple3#zipped so high in
the profiling output. I don't think it's zipped3's fault, more that it
figures prominently in a major consumer of compile time, but it's not
going to hurt to send it on its merry way.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@26066 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-11-24 01:24:47 +00:00
parent f07d22d397
commit 671b60e46a
1 changed files with 17 additions and 7 deletions

View File

@ -2166,14 +2166,24 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
def typedArgs(args: List[Tree], mode: Int) =
args mapConserve (arg => typedArg(arg, mode, 0, WildcardType))
def typedArgs(args: List[Tree], mode: Int, originalFormals: List[Type], adaptedFormals: List[Type]) = {
var newmodes = originalFormals map (tp => if (isByNameParamType(tp)) 0 else BYVALmode)
if (isVarArgTypes(originalFormals)) // TR check really necessary?
newmodes = newmodes.init ++ List.fill(args.length - originalFormals.length + 1)(STARmode | BYVALmode)
(args, adaptedFormals, newmodes).zipped map { (arg, formal, m) =>
typedArg(arg, mode, m, formal)
def typedArgs(args0: List[Tree], mode: Int, formals0: List[Type], adapted0: List[Type]): List[Tree] = {
val sticky = onlyStickyModes(mode)
def loop(args: List[Tree], formals: List[Type], adapted: List[Type]): List[Tree] = {
if (args.isEmpty || adapted.isEmpty) Nil
else {
// No formals left or * indicates varargs.
val isVarArgs = formals.isEmpty || formals.tail.isEmpty && isRepeatedParamType(formals.head)
val typedMode = sticky | (
if (isVarArgs) STARmode | BYVALmode
else if (isByNameParamType(formals.head)) 0
else BYVALmode
)
val tree = typedArg(args.head, mode, typedMode, adapted.head)
// formals may be empty, so don't call tail
tree :: loop(args.tail, formals drop 1, adapted.tail)
}
}
loop(args0, formals0, adapted0)
}
/** Does function need to be instantiated, because a missing parameter