aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-24 17:21:18 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-24 18:56:49 +0100
commita995ab85b7747275a1798cf29ac54466fbe82e2f (patch)
tree9ccf359de71fe9ade478932636ccba391f74b651 /src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
parented7755b781bd1b444d38329cb22eacaa3fc1c005 (diff)
downloaddotty-a995ab85b7747275a1798cf29ac54466fbe82e2f.tar.gz
dotty-a995ab85b7747275a1798cf29ac54466fbe82e2f.tar.bz2
dotty-a995ab85b7747275a1798cf29ac54466fbe82e2f.zip
Misc performance improvements by eliminating stupid allocations
- Avoid closure creation in Position. - Avoid creating debug string in SymDenotations - Avoid creating Flag translation tables in pickle buffers
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/PickleBuffer.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/PickleBuffer.scala39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala b/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
index b44d7f292..72007758c 100644
--- a/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
+++ b/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
@@ -166,6 +166,27 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
def times[T](n: Int, op: ()=>T): List[T] =
if (n == 0) List() else op() :: times(n-1, op)
+ /** Pickle = majorVersion_Nat minorVersion_Nat nbEntries_Nat {Entry}
+ * Entry = type_Nat length_Nat [actual entries]
+ *
+ * Assumes that the ..Version_Nat are already consumed.
+ *
+ * @return an array mapping entry numbers to locations in
+ * the byte array where the entries start.
+ */
+ def createIndex: Array[Int] = {
+ val index = new Array[Int](readNat()) // nbEntries_Nat
+ for (i <- 0 until index.length) {
+ index(i) = readIndex
+ readByte() // skip type_Nat
+ readIndex = readNat() + readIndex // read length_Nat, jump to next entry
+ }
+ index
+ }
+}
+
+object PickleBuffer {
+
private final val ScalaFlagEnd = 48
private final val ChunkBits = 8
private final val ChunkSize = 1 << ChunkBits
@@ -261,24 +282,6 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
(chunkMap(termMap), chunkMap(typeMap))
}
- /** Pickle = majorVersion_Nat minorVersion_Nat nbEntries_Nat {Entry}
- * Entry = type_Nat length_Nat [actual entries]
- *
- * Assumes that the ..Version_Nat are already consumed.
- *
- * @return an array mapping entry numbers to locations in
- * the byte array where the entries start.
- */
- def createIndex: Array[Int] = {
- val index = new Array[Int](readNat()) // nbEntries_Nat
- for (i <- 0 until index.length) {
- index(i) = readIndex
- readByte() // skip type_Nat
- readIndex = readNat() + readIndex // read length_Nat, jump to next entry
- }
- index
- }
-
def unpickleScalaFlags(sflags: Long, isType: Boolean): FlagSet = {
val map: FlagMap = if (isType) scalaTypeFlagMap else scalaTermFlagMap
val shift = ChunkBits