summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-07-23 14:22:06 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-07-23 14:32:30 +1000
commit342afbd52add51d616a68df531e882a8990c1192 (patch)
tree594fc59e0de827a237a24e34cb976a0e15f300da
parent1febfa59f79b9a4c078dc723c68e8b38dbda8c88 (diff)
downloadscala-342afbd52add51d616a68df531e882a8990c1192.tar.gz
scala-342afbd52add51d616a68df531e882a8990c1192.tar.bz2
scala-342afbd52add51d616a68df531e882a8990c1192.zip
Refactor to avoid duplicated work in Constructors
- Check if the clazz that owns all the decls we're filtering is effectively final once, rather than for each decl. - Query the full set of decls once.
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index 86685d46de..03e39ee329 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -165,11 +165,13 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL {
return
}
+ val isEffectivelyFinal = clazz.isEffectivelyFinal
def isParamCandidateForElision(sym: Symbol) = (sym.isParamAccessor && sym.isPrivateLocal)
- def isOuterCandidateForElision(sym: Symbol) = (sym.isOuterAccessor && sym.owner.isEffectivelyFinal && !sym.isOverridingSymbol)
+ def isOuterCandidateForElision(sym: Symbol) = (sym.isOuterAccessor && isEffectivelyFinal && !sym.isOverridingSymbol)
- val paramCandidatesForElision: Set[ /*Field*/ Symbol] = (clazz.info.decls.toSet filter isParamCandidateForElision)
- val outerCandidatesForElision: Set[ /*Method*/ Symbol] = (clazz.info.decls.toSet filter isOuterCandidateForElision)
+ val decls = clazz.info.decls.toSet
+ val paramCandidatesForElision: Set[ /*Field*/ Symbol] = (decls filter isParamCandidateForElision)
+ val outerCandidatesForElision: Set[ /*Method*/ Symbol] = (decls filter isOuterCandidateForElision)
omittables ++= paramCandidatesForElision
omittables ++= outerCandidatesForElision