Skip to content

Commit 218a673

Browse files
committed
Optimization: Make Reporter#unreportedWarnings an immutable map
1 parent 85a9257 commit 218a673

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,16 @@ abstract class Reporter extends interfaces.ReporterResult {
190190

191191
def reportNewFeatureUseSite(featureTrait: Symbol): Unit = reportedFeaturesUseSites += featureTrait
192192

193-
val unreportedWarnings: mutable.HashMap[String, Int] = new mutable.HashMap[String, Int] {
194-
override def default(key: String) = 0
195-
}
193+
var unreportedWarnings: Map[String, Int] = Map.empty
196194

197195
def report(m: MessageContainer)(implicit ctx: Context): Unit =
198196
if (!isHidden(m)) {
199197
doReport(m)(ctx.addMode(Mode.Printing))
200198
m match {
201-
case m: ConditionalWarning if !m.enablingOption.value => unreportedWarnings(m.enablingOption.name) += 1
199+
case m: ConditionalWarning if !m.enablingOption.value =>
200+
val key = m.enablingOption.name
201+
unreportedWarnings =
202+
unreportedWarnings.updated(key, unreportedWarnings.getOrElse(key, 0) + 1)
202203
case m: Warning => _warningCount += 1
203204
case m: Error =>
204205
errors = m :: errors

0 commit comments

Comments
 (0)