From de3669901a6c9551067071ab410775e57e3b26c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Sun, 5 Mar 2017 13:37:33 +0100 Subject: [PATCH] strconv: remove unused append rune width param MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Found by github.com/mvdan/unparam. Small performance win when the utf8.RuneLen call is removed. name old time/op new time/op delta AppendQuoteRune-4 21.7ns ± 0% 21.4ns ± 0% -1.38% (p=0.008 n=5+5) Change-Id: Ieb3b3e1148db7a3d854c81555a491edeff549f43 Reviewed-on: https://go-review.googlesource.com/37831 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/strconv/quote.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/strconv/quote.go b/src/strconv/quote.go index 76c5c2a1cb..db57065cac 100644 --- a/src/strconv/quote.go +++ b/src/strconv/quote.go @@ -32,7 +32,7 @@ func appendQuotedWith(buf []byte, s string, quote byte, ASCIIonly, graphicOnly b buf = append(buf, lowerhex[s[0]&0xF]) continue } - buf = appendEscapedRune(buf, r, width, quote, ASCIIonly, graphicOnly) + buf = appendEscapedRune(buf, r, quote, ASCIIonly, graphicOnly) } buf = append(buf, quote) return buf @@ -43,12 +43,12 @@ func appendQuotedRuneWith(buf []byte, r rune, quote byte, ASCIIonly, graphicOnly if !utf8.ValidRune(r) { r = utf8.RuneError } - buf = appendEscapedRune(buf, r, utf8.RuneLen(r), quote, ASCIIonly, graphicOnly) + buf = appendEscapedRune(buf, r, quote, ASCIIonly, graphicOnly) buf = append(buf, quote) return buf } -func appendEscapedRune(buf []byte, r rune, width int, quote byte, ASCIIonly, graphicOnly bool) []byte { +func appendEscapedRune(buf []byte, r rune, quote byte, ASCIIonly, graphicOnly bool) []byte { var runeTmp [utf8.UTFMax]byte if r == rune(quote) || r == '\\' { // always backslashed buf = append(buf, '\\') -- 2.48.1