Skip to content

Commit

Permalink
Avoid allocating tintError twice
Browse files Browse the repository at this point in the history
Passing the type-asserted tintError value as an error causes a second allocation.

Since the helper method is only for tintError values, change the signature to specify the concrete type to elide the second allocation.
  • Loading branch information
database64128 committed Dec 9, 2024
1 parent 7c923ea commit 5c5dcad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func (h *handler) appendValue(buf *buffer, v slog.Value, quote bool) {
}
}

func (h *handler) appendTintError(buf *buffer, err error, attrKey, groupsPrefix string) {
func (h *handler) appendTintError(buf *buffer, err tintError, attrKey, groupsPrefix string) {
buf.WriteStringIf(!h.noColor, ansiBrightRedFaint)
appendString(buf, groupsPrefix+attrKey, true)
buf.WriteByte('=')
Expand Down

0 comments on commit 5c5dcad

Please sign in to comment.