From 79652d8474419e181b6f27b3bad87d3acaef0e13 Mon Sep 17 00:00:00 2001 From: "Dr. Carsten Leue" Date: Wed, 7 Feb 2024 13:41:47 +0100 Subject: [PATCH] fix: disable inlining of debug functions Signed-off-by: Dr. Carsten Leue --- either/core.go | 4 ++++ option/core.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/either/core.go b/either/core.go index b502479..b9e40ae 100644 --- a/either/core.go +++ b/either/core.go @@ -30,6 +30,8 @@ type ( ) // String prints some debug info for the object +// +// go:noinline func eitherString(s *either) string { if s.isLeft { return fmt.Sprintf("Left[%T](%v)", s.value, s.value) @@ -38,6 +40,8 @@ func eitherString(s *either) string { } // Format prints some debug info for the object +// +// go:noinline func eitherFormat(e *either, f fmt.State, c rune) { switch c { case 's': diff --git a/option/core.go b/option/core.go index 23e33a4..06b9230 100644 --- a/option/core.go +++ b/option/core.go @@ -34,6 +34,8 @@ type Option[A any] struct { } // optString prints some debug info for the object +// +// go:noinline func optString(isSome bool, value any) string { if isSome { return fmt.Sprintf("Some[%T](%v)", value, value) @@ -42,6 +44,8 @@ func optString(isSome bool, value any) string { } // optFormat prints some debug info for the object +// +// go:noinline func optFormat(isSome bool, value any, f fmt.State, c rune) { switch c { case 's': @@ -72,6 +76,9 @@ func (s Option[A]) MarshalJSON() ([]byte, error) { return optMarshalJSON(s.isSome, s.value) } +// optUnmarshalJSON unmarshals the [Option] from a JSON string +// +// go:noinline func optUnmarshalJSON(isSome *bool, value any, data []byte) error { // decode the value if bytes.Equal(data, jsonNull) {