From e8b33f9286e796d9f04b9f265e40b9f3c48d5946 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Mon, 20 Jun 2011 15:25:23 -0400 Subject: [PATCH] lazy InputCache for recursive caches --- cache/SeparatedCache.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cache/SeparatedCache.scala b/cache/SeparatedCache.scala index 523716ac3..a126229bd 100644 --- a/cache/SeparatedCache.scala +++ b/cache/SeparatedCache.scala @@ -27,6 +27,16 @@ object InputCache def write(to: Out, i: I) = fmt.writes(to, i) def equiv = eqv } + def lzy[I](mkIn: => InputCache[I]): InputCache[I] = + new InputCache[I] + { + lazy val ic = mkIn + type Internal = ic.Internal + def convert(i: I) = ic convert i + def read(from: Input): ic.Internal = ic.read(from) + def write(to: Out, i: ic.Internal) = ic.write(to, i) + def equiv = ic.equiv + } } class BasicCache[I,O](implicit input: InputCache[I], outFormat: Format[O]) extends Cache[I,O]