Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #709 from adpi2/decoder-perf
[Scala 3 binary decoder] Cache decoded symbols
- Loading branch information
Showing
5 changed files
with
57 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...r/src/main/scala/ch/epfl/scala/debugadapter/internal/stacktrace/CachedBinaryDecoder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ch.epfl.scala.debugadapter.internal.stacktrace | ||
|
||
import ch.epfl.scala.debugadapter.internal.binary | ||
import ch.epfl.scala.debugadapter.internal.binary.Method | ||
import ch.epfl.scala.debugadapter.internal.binary.SignedName | ||
import tastyquery.Contexts.* | ||
import tastyquery.Symbols.* | ||
|
||
import scala.collection.concurrent.TrieMap | ||
|
||
class CachedBinaryDecoder(using Context, ThrowOrWarn) extends BinaryDecoder: | ||
private val classCache: TrieMap[String, DecodedClass] = TrieMap.empty | ||
private val methodCache: TrieMap[(String, SignedName), DecodedMethod] = TrieMap.empty | ||
private val liftedTreesCache: TrieMap[Symbol, Seq[LiftedTree[?]]] = TrieMap.empty | ||
|
||
override def decode(cls: binary.ClassType): DecodedClass = | ||
classCache.getOrElseUpdate(cls.name, super.decode(cls)) | ||
|
||
override def decode(method: Method): DecodedMethod = | ||
methodCache.getOrElseUpdate((method.declaringClass.name, method.signedName), super.decode(method)) | ||
|
||
override protected def collectAllLiftedTrees(owner: Symbol): Seq[LiftedTree[?]] = | ||
liftedTreesCache.getOrElseUpdate(owner, super.collectAllLiftedTrees(owner)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters