summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-05-17 07:58:34 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-05-21 22:51:35 +0200
commitd190139373ef265b62f6ca499a1bc360b5fc0e8a (patch)
treefbce913087319638d0a79bb9da0833e17a444cd3
parent9d80fd0148ba7466bbb47e661aea33ee930a0d32 (diff)
downloadscala-d190139373ef265b62f6ca499a1bc360b5fc0e8a.tar.gz
scala-d190139373ef265b62f6ca499a1bc360b5fc0e8a.tar.bz2
scala-d190139373ef265b62f6ca499a1bc360b5fc0e8a.zip
Re-use the exsiting range of the name table when using subName.
The sub-name can just point to a smaller range of the array.
-rw-r--r--src/reflect/scala/reflect/internal/Names.scala14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala
index 05c060e81f..b50f324074 100644
--- a/src/reflect/scala/reflect/internal/Names.scala
+++ b/src/reflect/scala/reflect/internal/Names.scala
@@ -107,12 +107,18 @@ trait Names extends api.Names {
// The logic order here is future-proofing against the possibility
// that name.toString will become an eager val, in which case the call
// to enterChars cannot follow the construction of the TermName.
- val ncStart = nc
- enterChars(cs, offset, len)
+ var startIndex = 0
+ if (cs == chrs) {
+ // Optimize for subName, the new name is already stored in chrs
+ startIndex = offset
+ } else {
+ startIndex = nc
+ enterChars(cs, offset, len)
+ }
val next = termHashtable(h)
val termName =
- if (cachedString ne null) new TermName_S(ncStart, len, next, cachedString)
- else new TermName_R(ncStart, len, next)
+ if (cachedString ne null) new TermName_S(startIndex, len, next, cachedString)
+ else new TermName_R(startIndex, len, next)
// Add the new termName to the hashtable only after it's been fully constructed
termHashtable(h) = termName
termName