Skip to content

Commit

Permalink
fix: disable inlining of debug functions
Browse files Browse the repository at this point in the history
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
  • Loading branch information
CarstenLeue committed Feb 7, 2024
1 parent a774d63 commit 79652d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions either/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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':
Expand Down
7 changes: 7 additions & 0 deletions option/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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':
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 79652d8

Please sign in to comment.