From aadffd5b675254ce6235b74353ac260d2a5848e1 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 20 Nov 2018 18:35:56 +0000 Subject: [PATCH] mime: remove allocation introduced in recent fix CL 150417 was submitted before I could recommend this change to remove an unnecessary allocation. Updates #28849 Change-Id: I4cd655f62bb3d00eda6c997f074785385bceee0c Reviewed-on: https://go-review.googlesource.com/c/150498 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/mime/mediatype.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mime/mediatype.go b/src/mime/mediatype.go index fc6e0d0673d..05390773a8a 100644 --- a/src/mime/mediatype.go +++ b/src/mime/mediatype.go @@ -56,7 +56,8 @@ func FormatMediaType(t string, param map[string]string) string { b.WriteByte('"') offset := 0 - for index, character := range []byte(value) { + for index := 0; index < len(value); index++ { + character := value[index] if character == '"' || character == '\\' { b.WriteString(value[offset:index]) offset = index