diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/runtime/Memoizer.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/scala/reflect/runtime/Memoizer.scala b/src/compiler/scala/reflect/runtime/Memoizer.scala new file mode 100644 index 0000000000..4c1b82ae6d --- /dev/null +++ b/src/compiler/scala/reflect/runtime/Memoizer.scala @@ -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 + } +} |