Skip to content

Commit 342afbd

Browse files
committed
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.
1 parent 1febfa5 commit 342afbd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL {
165165
return
166166
}
167167

168+
val isEffectivelyFinal = clazz.isEffectivelyFinal
168169
def isParamCandidateForElision(sym: Symbol) = (sym.isParamAccessor && sym.isPrivateLocal)
169-
def isOuterCandidateForElision(sym: Symbol) = (sym.isOuterAccessor && sym.owner.isEffectivelyFinal && !sym.isOverridingSymbol)
170+
def isOuterCandidateForElision(sym: Symbol) = (sym.isOuterAccessor && isEffectivelyFinal && !sym.isOverridingSymbol)
170171

171-
val paramCandidatesForElision: Set[ /*Field*/ Symbol] = (clazz.info.decls.toSet filter isParamCandidateForElision)
172-
val outerCandidatesForElision: Set[ /*Method*/ Symbol] = (clazz.info.decls.toSet filter isOuterCandidateForElision)
172+
val decls = clazz.info.decls.toSet
173+
val paramCandidatesForElision: Set[ /*Field*/ Symbol] = (decls filter isParamCandidateForElision)
174+
val outerCandidatesForElision: Set[ /*Method*/ Symbol] = (decls filter isOuterCandidateForElision)
173175

174176
omittables ++= paramCandidatesForElision
175177
omittables ++= outerCandidatesForElision

0 commit comments

Comments
 (0)