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:
parent
85b31691ce
commit
59f3ce8902
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue