From baad6aa227ef608de33ddfaa8f059aa258bd3e64 Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Tue, 10 Sep 2024 16:42:57 -0400 Subject: [PATCH] Memo.Invalidate zeros out the held value automatically InvalidateTo is no longer needed --- container/memo.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/container/memo.go b/container/memo.go index 351821b..2496fa7 100644 --- a/container/memo.go +++ b/container/memo.go @@ -27,13 +27,8 @@ func (this *Memo[T]) Value () T { // Invalidate marks the Memo's value as invalid, which will cause it to be // updated the next time Value is called. func (this *Memo[T]) Invalidate () { + var zero T + this.cache = zero this.valid = false } -// InvalidateTo invalidates the Memo and sets its value. The new value will be -// entirely inaccessible. This is only intended to be used for setting a -// reference to nil -func (this *Memo[T]) InvalidateTo (value T) { - this.Invalidate() - this.cache = value -}