Skip to content

Commit d93907e

Browse files
committed
Performance improvement: Avoid unncecessary allocations of ListBuffer
There were a lot in StoreReporter, as we are creating about 0.5M new ones per self-compile.
1 parent 32c041c commit d93907e

File tree

3 files changed

+4
-235
lines changed

3 files changed

+4
-235
lines changed

bin/dotc

Lines changed: 0 additions & 232 deletions
This file was deleted.

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class Definitions {
282282

283283
object FunctionType {
284284
def apply(args: List[Type], resultType: Type) =
285-
FunctionClass(args.length).typeRef.appliedTo(args :+ resultType)
285+
FunctionClass(args.length).typeRef.appliedTo(args ::: resultType :: Nil)
286286
def unapply(ft: Type): Option[(List[Type], Type)] = { // Dotty deviation: Type annotation needed because inferred type
287287
// is Some[(List[Type], Type)] | None, which is not a legal unapply type.
288288
val tsym = ft.typeSymbol

src/dotty/tools/dotc/reporting/StoreReporter.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import config.Printers._
1212
*/
1313
class StoreReporter extends Reporter {
1414

15-
val infos = new mutable.ListBuffer[Diagnostic]
15+
private var infos: mutable.ListBuffer[Diagnostic] = null
1616

1717
protected def doReport(d: Diagnostic)(implicit ctx: Context): Unit = {
1818
typr.println(s">>>> StoredError: ${d.msg}") // !!! DEBUG
19+
if (infos == null) infos = new mutable.ListBuffer
1920
infos += d
2021
}
2122

2223
override def flush()(implicit ctx: Context) =
23-
infos foreach ctx.reporter.report
24+
if (infos != null) infos foreach ctx.reporter.report
2425
}

0 commit comments

Comments
 (0)