Skip to content

Commit

Permalink
Prealloc msgs in multierr.Error (#1209)
Browse files Browse the repository at this point in the history
"msgs"'s length is known, preallocate it can save memories.

Co-authored-by: Chris Roche <[email protected]>
  • Loading branch information
apocelipes and rodaine authored Jan 2, 2025
1 parent d1191c8 commit c220710
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion templates/goshared/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type {{ multierrname . }} []error
// Error returns a concatenation of all the error messages it wraps.
func (m {{ multierrname . }}) Error() string {
var msgs []string
msgs := make([]string, 0, len(m))
for _, err := range m {
msgs = append(msgs, err.Error())
}
Expand Down

0 comments on commit c220710

Please sign in to comment.