Skip to content

Commit c220710

Browse files
apocelipesrodaine
andauthored
Prealloc msgs in multierr.Error (#1209)
"msgs"'s length is known, preallocate it can save memories. Co-authored-by: Chris Roche <[email protected]>
1 parent d1191c8 commit c220710

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/goshared/msg.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type {{ multierrname . }} []error
9595
9696
// Error returns a concatenation of all the error messages it wraps.
9797
func (m {{ multierrname . }}) Error() string {
98-
var msgs []string
98+
msgs := make([]string, 0, len(m))
9999
for _, err := range m {
100100
msgs = append(msgs, err.Error())
101101
}

0 commit comments

Comments
 (0)