Class that can be used for memoizing types in reified trees

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25562 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
odersky 2011-08-24 17:06:04 +00:00
parent 85b31691ce
commit 59f3ce8902
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package scala.reflect.runtime
import collection.mutable.ArrayBuffer
import Mirror.Type
/** Class that can be used for memoizing types in reified trees */
class Memoizer {
private val mem = new ArrayBuffer[Mirror.Type]
def get(n: Int): Type = mem(n)
def add(n: Int, tpe: Type): Type = {
while (mem.length <= n) mem += null
mem(n) = tpe
tpe
}
}