From 94ecbc26168965a670a0f7cf86f658131c790a9c Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 15 Aug 2024 16:46:35 +0200 Subject: [PATCH] internal/impl: remove unused ExtensionField.SetLazy method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This cleanup was done in June 2020 by Dan Scales, but never upstreamed to the open source Go Protobuf repository. Change-Id: I175d9588b5bb536fa276133f8fe6073278e6d3b0 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/605895 Reviewed-by: Christian Höppner LUCI-TryBot-Result: Go LUCI --- internal/impl/codec_extension.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/internal/impl/codec_extension.go b/internal/impl/codec_extension.go index 4bb0a7a2..0d5b546e 100644 --- a/internal/impl/codec_extension.go +++ b/internal/impl/codec_extension.go @@ -67,7 +67,6 @@ type lazyExtensionValue struct { xi *extensionFieldInfo value protoreflect.Value b []byte - fn func() protoreflect.Value } type ExtensionField struct { @@ -158,10 +157,9 @@ func (f *ExtensionField) lazyInit() { } f.lazy.value = val } else { - f.lazy.value = f.lazy.fn() + panic("No support for lazy fns for ExtensionField") } f.lazy.xi = nil - f.lazy.fn = nil f.lazy.b = nil atomic.StoreUint32(&f.lazy.atomicOnce, 1) } @@ -174,13 +172,6 @@ func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value) f.lazy = nil } -// SetLazy sets the type and a value that is to be lazily evaluated upon first use. -// This must not be called concurrently. -func (f *ExtensionField) SetLazy(t protoreflect.ExtensionType, fn func() protoreflect.Value) { - f.typ = t - f.lazy = &lazyExtensionValue{fn: fn} -} - // Value returns the value of the extension field. // This may be called concurrently. func (f *ExtensionField) Value() protoreflect.Value {