From ed003fcac668522aff80dd9100e5d314e0effab1 Mon Sep 17 00:00:00 2001 From: 1911860538 Date: Wed, 25 Dec 2024 20:22:45 +0800 Subject: [PATCH] internal/fuzz: optimize MalformedCorpusError.Error method memory allocation --- src/internal/fuzz/fuzz.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index e406c8c400400a..7acbd114695660 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -963,9 +963,9 @@ type MalformedCorpusError struct { } func (e *MalformedCorpusError) Error() string { - var msgs []string - for _, s := range e.errs { - msgs = append(msgs, s.Error()) + msgs := make([]string, len(e.errs)) + for i, s := range e.errs { + msgs[i] = s.Error() } return strings.Join(msgs, "\n") }