Skip to content

Commit 3e08c5d

Browse files
committed
Avoid withFilter in some warm spots
1 parent 73b5666 commit 3e08c5d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import reporting.trace
1010
import dotty.tools.dotc.transform.SymUtils._
1111
import Decorators._
1212
import Constants.Constant
13+
import scala.collection.mutable
1314

1415
import scala.annotation.tailrec
1516

@@ -698,7 +699,10 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
698699

699700
/** The symbols defined locally in a statement list */
700701
def localSyms(stats: List[Tree])(using Context): List[Symbol] =
701-
for (stat <- stats if stat.isDef && stat.symbol.exists) yield stat.symbol
702+
val locals = new mutable.ListBuffer[Symbol]
703+
for stat <- stats do
704+
if stat.isDef && stat.symbol.exists then locals += stat.symbol
705+
locals.toList
702706

703707
/** If `tree` is a DefTree, the symbol defined by it, otherwise NoSymbol */
704708
def definedSym(tree: Tree)(using Context): Symbol =

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,11 @@ object RefChecks {
828828
* in either a deprecated member or a scala bridge method, issue a warning.
829829
*/
830830
private def checkDeprecated(sym: Symbol, pos: SourcePosition)(using Context): Unit =
831-
for
832-
annot <- sym.getAnnotation(defn.DeprecatedAnnot)
833-
if !ctx.owner.ownersIterator.exists(_.isDeprecated)
834-
do
835-
val msg = annot.argumentConstant(0).map(": " + _.stringValue).getOrElse("")
836-
val since = annot.argumentConstant(1).map(" since " + _.stringValue).getOrElse("")
837-
report.deprecationWarning(s"${sym.showLocated} is deprecated${since}${msg}", pos)
831+
for annot <- sym.getAnnotation(defn.DeprecatedAnnot) do
832+
if !ctx.owner.ownersIterator.exists(_.isDeprecated) then
833+
val msg = annot.argumentConstant(0).map(": " + _.stringValue).getOrElse("")
834+
val since = annot.argumentConstant(1).map(" since " + _.stringValue).getOrElse("")
835+
report.deprecationWarning(s"${sym.showLocated} is deprecated${since}${msg}", pos)
838836

839837
/** If @migration is present (indicating that the symbol has changed semantics between versions),
840838
* emit a warning.

0 commit comments

Comments
 (0)