From 4608c427eb27315b9cc073677e7280ba3384f564 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 3 Feb 2013 15:42:16 +0100 Subject: Introduces caching for condensed contexts --- src/dotty/tools/dotc/core/Contexts.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/dotty/tools/dotc') diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 6a674dba8..1dc7ff2c1 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -69,16 +69,22 @@ object Contexts { def inform(msg: String) = ??? def informTime(msg: String, start: Long): Unit = ??? + private var _condensed: CondensedContext = null + def condensed: CondensedContext = { + if (_condensed == null) + _condensed = base.initialCtx.fresh + .withPeriod(period) + .withPrinter(printer) + .withSettings(sstate) + _condensed + } + def fresh: FreshContext = { val newctx = super.clone.asInstanceOf[FreshContext] newctx.underlying = this + newctx._condensed = null newctx } - - def condensed: CondensedContext = base.initialCtx.fresh - .withPeriod(period) - .withPrinter(printer) - .withSettings(sstate) } abstract class CondensedContext extends Context @@ -110,7 +116,7 @@ object Contexts { val settings = new ScalaSettings - val initialCtx: Context = new InitialContext(this).fresh + val initialCtx: Context = new InitialContext(this) .withSettings(settings.defaultState) val loaders = new SymbolLoaders -- cgit v1.2.3