memoize the creation of the name in the blame object

This commit is contained in:
Robby Findler 2018-05-02 18:53:48 -05:00
parent 822938d9ae
commit 3f4cbcbfd8

View File

@ -76,10 +76,17 @@
(unless positive
(raise-type-error 'make-blame "(not/c #f)" 3
source value build-name positive negative original?))
(define build/memo-name
(let* ([uniq (box #f)]
[ans uniq])
(λ ()
(when (eq? uniq ans)
(set! ans (build-name)))
ans)))
(make-blame
source
value
build-name
build/memo-name
(list positive)
(and negative (list negative))
original?