Stop filling json codec cache

These were not actually used as far as I could tell. The json codecs
cache showed up as taking up 30MB in a heap dump that I took after
running compile 30 times in a clone of the repro project in
https://github.com/sbt/sbt/issues/5508.
This commit is contained in:
Ethan Atkins 2020-07-29 16:06:43 -07:00
parent 6c50a85f93
commit 46724159da
1 changed files with 9 additions and 7 deletions

View File

@ -24,7 +24,6 @@ sealed abstract class LogExchange {
private[sbt] lazy val context: LoggerContext = init()
private[sbt] lazy val builtInStringCodecs: Unit = initStringCodecs()
private[sbt] lazy val asyncStdout: AsyncAppender = buildAsyncStdout
private[sbt] val jsonCodecs: concurrent.Map[String, JsonFormat[_]] = concurrent.TrieMap()
private[sbt] val stringCodecs: concurrent.Map[String, ShowLines[_]] = concurrent.TrieMap()
def logger(name: String): ManagedLogger = logger(name, None, None)
@ -100,12 +99,15 @@ sealed abstract class LogExchange {
lo
}
def jsonCodec[A](tag: String): Option[JsonFormat[A]] =
jsonCodecs.get(tag) map { _.asInstanceOf[JsonFormat[A]] }
def hasJsonCodec(tag: String): Boolean =
jsonCodecs.contains(tag)
def getOrElseUpdateJsonCodec[A](tag: String, v: JsonFormat[A]): JsonFormat[A] =
jsonCodecs.getOrElseUpdate(tag, v).asInstanceOf[JsonFormat[A]]
@deprecated("It is now necessary to provide a json format instance", "1.4.0")
def jsonCodec[A](tag: String): Option[JsonFormat[A]] = None
@deprecated("Always returns false", "1.4.0")
def hasJsonCodec(tag: String): Boolean = false
@deprecated("This is a no-op", "1.4.0")
def getOrElseUpdateJsonCodec[A](tag: String, v: JsonFormat[A]): JsonFormat[A] = v
@deprecated("The log manager no longer caches jsonCodecs", "1.4.0")
def jsonCodecs(): concurrent.Map[String, JsonFormat[_]] = concurrent.TrieMap.empty
def stringCodec[A](tag: String): Option[ShowLines[A]] =
stringCodecs.get(tag) map { _.asInstanceOf[ShowLines[A]] }
def hasStringCodec(tag: String): Boolean =