Skip to content

Commit

Permalink
Add comment on special handling for single marshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv committed Apr 19, 2023
1 parent 26b53cc commit c9125d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zapcore/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func encodeError(key string, err error, enc ObjectEncoder) (retErr error) {

switch {
case len(marshalers) == 1:
// Special-case handling of single marshaler to avoid an alloc
// converting mergedMarshalers to an ObjectMarshaler interface.
if err := enc.AddObject(key+"Fields", marshalers[0]); err != nil {
return err
}
Expand Down

0 comments on commit c9125d3

Please sign in to comment.