diff options
author | Martin Odersky <odersky@gmail.com> | 2017-04-01 11:32:03 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 09:33:12 +0200 |
commit | 9f7012e886aa13f22e6ffc417050f9f6fc5b8003 (patch) | |
tree | c78f53848b4bb550739b969b65f1132f210b2130 /compiler/src/dotty/tools/dotc | |
parent | c646883fbe6c2fffaa8f64d64e46bc85b58def25 (diff) | |
download | dotty-9f7012e886aa13f22e6ffc417050f9f6fc5b8003.tar.gz dotty-9f7012e886aa13f22e6ffc417050f9f6fc5b8003.tar.bz2 dotty-9f7012e886aa13f22e6ffc417050f9f6fc5b8003.zip |
Memoize toSimpleName
toSimpleName is called a lot from the backend, so it makes
sense to memoize it. It would be even better to communicate
with the backend using strings, because then we would not
have to enter all these simple names in the name table.
Diffstat (limited to 'compiler/src/dotty/tools/dotc')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Names.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala index 95cc2fef7..352fa6b6b 100644 --- a/compiler/src/dotty/tools/dotc/core/Names.scala +++ b/compiler/src/dotty/tools/dotc/core/Names.scala @@ -339,7 +339,12 @@ object Names { def isSimple = false def asSimpleName = throw new UnsupportedOperationException(s"$debugString is not a simple name") - def toSimpleName = termName(toString) + + private var simpleName: SimpleTermName = null + def toSimpleName = { + if (simpleName == null) simpleName = termName(toString) + simpleName + } def rewrite(f: PartialFunction[Name, Name]): ThisName = if (f.isDefinedAt(this)) likeSpaced(f(this)) |