mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: delete Runes, Bytes
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench delete unused imports R=r CC=golang-dev https://golang.org/cl/224062
This commit is contained in:
parent
dfaa6eaa76
commit
9750adbbad
65 changed files with 239 additions and 310 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -30,69 +29,71 @@ const testInput = `
|
|||
</body><!-- missing final newline -->`
|
||||
|
||||
var rawTokens = []Token{
|
||||
CharData(strings.Bytes("\n")),
|
||||
ProcInst{"xml", strings.Bytes(`version="1.0" encoding="UTF-8"`)},
|
||||
CharData(strings.Bytes("\n")),
|
||||
Directive(strings.Bytes(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`)),
|
||||
CharData(strings.Bytes("\n")),
|
||||
CharData([]byte("\n")),
|
||||
ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)},
|
||||
CharData([]byte("\n")),
|
||||
Directive([]byte(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`),
|
||||
),
|
||||
CharData([]byte("\n")),
|
||||
StartElement{Name{"", "body"}, []Attr{Attr{Name{"xmlns", "foo"}, "ns1"}, Attr{Name{"", "xmlns"}, "ns2"}, Attr{Name{"xmlns", "tag"}, "ns3"}}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"", "hello"}, []Attr{Attr{Name{"", "lang"}, "en"}}},
|
||||
CharData(strings.Bytes("World <>'\" 白鵬翔")),
|
||||
CharData([]byte("World <>'\" 白鵬翔")),
|
||||
EndElement{Name{"", "hello"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"", "goodbye"}, nil},
|
||||
EndElement{Name{"", "goodbye"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"", "outer"}, []Attr{Attr{Name{"foo", "attr"}, "value"}, Attr{Name{"xmlns", "tag"}, "ns4"}}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"", "inner"}, nil},
|
||||
EndElement{Name{"", "inner"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
EndElement{Name{"", "outer"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"tag", "name"}, nil},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData(strings.Bytes("Some text here.")),
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
CharData([]byte("Some text here.")),
|
||||
CharData([]byte("\n ")),
|
||||
EndElement{Name{"tag", "name"}},
|
||||
CharData(strings.Bytes("\n")),
|
||||
CharData([]byte("\n")),
|
||||
EndElement{Name{"", "body"}},
|
||||
Comment(strings.Bytes(" missing final newline ")),
|
||||
Comment([]byte(" missing final newline ")),
|
||||
}
|
||||
|
||||
var cookedTokens = []Token{
|
||||
CharData(strings.Bytes("\n")),
|
||||
ProcInst{"xml", strings.Bytes(`version="1.0" encoding="UTF-8"`)},
|
||||
CharData(strings.Bytes("\n")),
|
||||
Directive(strings.Bytes(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`)),
|
||||
CharData(strings.Bytes("\n")),
|
||||
CharData([]byte("\n")),
|
||||
ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)},
|
||||
CharData([]byte("\n")),
|
||||
Directive([]byte(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`),
|
||||
),
|
||||
CharData([]byte("\n")),
|
||||
StartElement{Name{"ns2", "body"}, []Attr{Attr{Name{"xmlns", "foo"}, "ns1"}, Attr{Name{"", "xmlns"}, "ns2"}, Attr{Name{"xmlns", "tag"}, "ns3"}}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"ns2", "hello"}, []Attr{Attr{Name{"", "lang"}, "en"}}},
|
||||
CharData(strings.Bytes("World <>'\" 白鵬翔")),
|
||||
CharData([]byte("World <>'\" 白鵬翔")),
|
||||
EndElement{Name{"ns2", "hello"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"ns2", "goodbye"}, nil},
|
||||
EndElement{Name{"ns2", "goodbye"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"ns2", "outer"}, []Attr{Attr{Name{"ns1", "attr"}, "value"}, Attr{Name{"xmlns", "tag"}, "ns4"}}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"ns2", "inner"}, nil},
|
||||
EndElement{Name{"ns2", "inner"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
EndElement{Name{"ns2", "outer"}},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
StartElement{Name{"ns3", "name"}, nil},
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData(strings.Bytes("Some text here.")),
|
||||
CharData(strings.Bytes("\n ")),
|
||||
CharData([]byte("\n ")),
|
||||
CharData([]byte("Some text here.")),
|
||||
CharData([]byte("\n ")),
|
||||
EndElement{Name{"ns3", "name"}},
|
||||
CharData(strings.Bytes("\n")),
|
||||
CharData([]byte("\n")),
|
||||
EndElement{Name{"ns2", "body"}},
|
||||
Comment(strings.Bytes(" missing final newline ")),
|
||||
Comment([]byte(" missing final newline ")),
|
||||
}
|
||||
|
||||
var xmlInput = []string{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue