diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-05 14:26:01 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-05 15:25:58 -0800 |
commit | 020053c3215579e8aeb871a4ad0078516994270d (patch) | |
tree | 447f518a7361a9a49993a22012b37a5c653e6284 /src/compiler/scala/tools/nsc/typechecker/Unapplies.scala | |
parent | 749b476beca481b48cad8ea3810865634a010686 (diff) | |
download | scala-020053c3215579e8aeb871a4ad0078516994270d.tar.gz scala-020053c3215579e8aeb871a4ad0078516994270d.tar.bz2 scala-020053c3215579e8aeb871a4ad0078516994270d.zip |
More consistent use of Names.
Several large helpings of tedium later, fewer strings are being
discarded like so much refuse. Some names now cache a String, but only
"named Names", so it's not very many and they pay for themselves pretty
quickly. Many fewer name-related implicit conversions now taking place.
A number of efficiency related measures.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Unapplies.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Unapplies.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 9b69c847f6..fd6f972ffc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -21,6 +21,8 @@ trait Unapplies extends ast.TreeDSL import CODE.{ CASE => _, _ } import treeInfo.{ isRepeatedParamType, isByNameParamType } + private val unapplyParamName = newTermName("x$0") + /** returns type list for return type of the extraction */ def unapplyTypeList(ufn: Symbol, ufntpe: Type) = { assert(ufn.isMethod) @@ -173,14 +175,13 @@ trait Unapplies extends ast.TreeDSL */ def caseModuleUnapplyMeth(cdef: ClassDef): DefDef = { val tparams = cdef.tparams map copyUntypedInvariant - val paramName = newTermName("x$0") val method = constrParamss(cdef) match { case xs :: _ if xs.nonEmpty && isRepeatedParamType(xs.last.tpt) => nme.unapplySeq case _ => nme.unapply } - val cparams = List(ValDef(Modifiers(PARAM | SYNTHETIC), paramName, classType(cdef, tparams), EmptyTree)) + val cparams = List(ValDef(Modifiers(PARAM | SYNTHETIC), unapplyParamName, classType(cdef, tparams), EmptyTree)) val ifNull = if (constrParamss(cdef).head.isEmpty) FALSE else REF(NoneModule) - val body = nullSafe({ case Ident(x) => caseClassUnapplyReturnValue(x, cdef.symbol) }, ifNull)(Ident(paramName)) + val body = nullSafe({ case Ident(x) => caseClassUnapplyReturnValue(x, cdef.symbol) }, ifNull)(Ident(unapplyParamName)) atPos(cdef.pos.focus)( DefDef(caseMods, method, tparams, List(cparams), TypeTree(), body) |