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
|
|
@ -302,23 +302,3 @@ func TrimSpace(s string) string {
|
|||
}
|
||||
return s[start:end]
|
||||
}
|
||||
|
||||
// Bytes returns a new slice containing the bytes in s.
|
||||
func Bytes(s string) []byte {
|
||||
b := make([]byte, len(s))
|
||||
for i := 0; i < len(s); i++ {
|
||||
b[i] = s[i]
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Runes returns a slice of runes (Unicode code points) equivalent to the string s.
|
||||
func Runes(s string) []int {
|
||||
t := make([]int, utf8.RuneCountInString(s))
|
||||
i := 0
|
||||
for _, r := range s {
|
||||
t[i] = r
|
||||
i++
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue