diff --git a/render/memoise.go b/render/memoise.go index 6f96e1c397..93859327d8 100644 --- a/render/memoise.go +++ b/render/memoise.go @@ -27,6 +27,9 @@ type memoise struct { // Memoise wraps the renderer in a loving embrace of caching. func Memoise(r Renderer) Renderer { + if _, ok := r.(*memoise); ok { + return r // fixpoint + } return &memoise{ Renderer: r, id: fmt.Sprintf("%x", rand.Int63()), diff --git a/render/memoise_test.go b/render/memoise_test.go index 9d7954ae97..79c779a362 100644 --- a/render/memoise_test.go +++ b/render/memoise_test.go @@ -20,6 +20,11 @@ func TestMemoise(t *testing.T) { return render.Nodes{Nodes: report.Nodes{rpt.ID: report.MakeNode(rpt.ID)}} }) m := render.Memoise(r) + + if render.Memoise(m) != m { + t.Errorf("Memoised renderers should be fixpoints.") + } + rpt1 := report.MakeReport() result1 := m.Render(rpt1)