]> Cypherpunks repositories - gostls13.git/commitdiff
strconv: remove unused append rune width param
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 5 Mar 2017 12:37:33 +0000 (13:37 +0100)
committerIan Lance Taylor <iant@golang.org>
Mon, 6 Mar 2017 04:37:13 +0000 (04:37 +0000)
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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/strconv/quote.go

index 76c5c2a1cbb4d54f745952622c2b3fcbf8bcffe4..db57065cac1c3ab651c63d0785a8c73d7c029bc5 100644 (file)
@@ -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, '\\')