]> Cypherpunks repositories - gostls13.git/commitdiff
undo CL 12486043 / ab644299d124
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 5 Aug 2013 23:27:24 +0000 (16:27 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 5 Aug 2013 23:27:24 +0000 (16:27 -0700)
Uglier.

««« original CL description
all: use strings.IndexByte instead of Index where possible

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12485044

21 files changed:
src/pkg/crypto/x509/pem_decrypt.go
src/pkg/debug/gosym/symtab.go
src/pkg/encoding/json/tags.go
src/pkg/encoding/xml/typeinfo.go
src/pkg/encoding/xml/xml.go
src/pkg/go/build/build.go
src/pkg/go/printer/printer.go
src/pkg/math/big/rat.go
src/pkg/mime/mediatype.go
src/pkg/net/http/cgi/child.go
src/pkg/net/http/cookie.go
src/pkg/net/http/fs.go
src/pkg/net/http/request.go
src/pkg/net/http/server.go
src/pkg/net/url/url.go
src/pkg/os/os_test.go
src/pkg/os/user/lookup_unix.go
src/pkg/path/match.go
src/pkg/regexp/exec_test.go
src/pkg/regexp/regexp.go
src/pkg/unicode/maketables.go

index fda03b233d77204d71fc3b22b4b76a16e49f7c3b..194c81bf688c8eb5be8ab03bb4878bf15d049f5d 100644 (file)
@@ -115,7 +115,7 @@ func DecryptPEMBlock(b *pem.Block, password []byte) ([]byte, error) {
                return nil, errors.New("x509: no DEK-Info header in block")
        }
 
-       idx := strings.IndexByte(dek, ',')
+       idx := strings.Index(dek, ",")
        if idx == -1 {
                return nil, errors.New("x509: malformed DEK-Info header")
        }
index c6952af55caff48c076253a76f4a0e7b9a990230..9ab05bac2f70af17e9edb7417956eb56e196f8df 100644 (file)
@@ -40,7 +40,7 @@ func (s *Sym) Static() bool { return s.Type >= 'a' }
 // PackageName returns the package part of the symbol name,
 // or the empty string if there is none.
 func (s *Sym) PackageName() string {
-       if i := strings.IndexByte(s.Name, '.'); i != -1 {
+       if i := strings.Index(s.Name, "."); i != -1 {
                return s.Name[0:i]
        }
        return ""
@@ -49,7 +49,7 @@ func (s *Sym) PackageName() string {
 // ReceiverName returns the receiver type name of this symbol,
 // or the empty string if there is none.
 func (s *Sym) ReceiverName() string {
-       l := strings.IndexByte(s.Name, '.')
+       l := strings.Index(s.Name, ".")
        r := strings.LastIndex(s.Name, ".")
        if l == -1 || r == -1 || l == r {
                return ""
index 6a8d03a5df24fbe6f4bddf5b5f3c1e9d3d84dbaf..c38fd5102f6302deb1e10639dbe4552ee255837e 100644 (file)
@@ -15,7 +15,7 @@ type tagOptions string
 // parseTag splits a struct field's json tag into its name and
 // comma-separated options.
 func parseTag(tag string) (string, tagOptions) {
-       if idx := strings.IndexByte(tag, ','); idx != -1 {
+       if idx := strings.Index(tag, ","); idx != -1 {
                return tag[:idx], tagOptions(tag[idx+1:])
        }
        return tag, tagOptions("")
@@ -31,7 +31,7 @@ func (o tagOptions) Contains(optionName string) bool {
        s := string(o)
        for s != "" {
                var next string
-               i := strings.IndexByte(s, ',')
+               i := strings.Index(s, ",")
                if i >= 0 {
                        s, next = s[:i], s[i+1:]
                }
index fb9f782e45e2d5e101abcad57bd443fc2f227aa1..83e65402c00ebf6f0529402771a6879497b5c0c9 100644 (file)
@@ -113,7 +113,7 @@ func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro
 
        // Split the tag from the xml namespace if necessary.
        tag := f.Tag.Get("xml")
-       if i := strings.IndexByte(tag, ' '); i >= 0 {
+       if i := strings.Index(tag, " "); i >= 0 {
                finfo.xmlns, tag = tag[:i], tag[i+1:]
        }
 
index a6ef87ac872c342bd869deee168489ddc74f520a..2f36604797df01a7257bbfc6e41b1d592f3ea8f4 100644 (file)
@@ -1026,7 +1026,7 @@ func (d *Decoder) nsname() (name Name, ok bool) {
        if !ok {
                return
        }
-       i := strings.IndexByte(s, ':')
+       i := strings.Index(s, ":")
        if i < 0 {
                name.Local = s
        } else {
index cdf8ba91965181b6422a66321d15642bae86843b..38de9ba07f70738e79892dd5a064c73a7225f829 100644 (file)
@@ -877,7 +877,7 @@ func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup)
 
                // Split at colon.
                line = strings.TrimSpace(line[4:])
-               i := strings.IndexByte(line, ':')
+               i := strings.Index(line, ":")
                if i < 0 {
                        return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig)
                }
@@ -1022,7 +1022,7 @@ func (ctxt *Context) match(name string) bool {
        if name == "" {
                return false
        }
-       if i := strings.IndexByte(name, ','); i >= 0 {
+       if i := strings.Index(name, ","); i >= 0 {
                // comma-separated list
                return ctxt.match(name[:i]) && ctxt.match(name[i+1:])
        }
@@ -1076,7 +1076,7 @@ func (ctxt *Context) match(name string) bool {
 //     name_$(GOOS)_$(GOARCH)_test.*
 //
 func (ctxt *Context) goodOSArchFile(name string) bool {
-       if dot := strings.IndexByte(name, '.'); dot != -1 {
+       if dot := strings.Index(name, "."); dot != -1 {
                name = name[:dot]
        }
        l := strings.Split(name, "_")
index af9742c430c3136cca2525b3e387fb88e173a3b9..e06d2edfb21c2e8da51d07c2c9f572c21a99c3e3 100644 (file)
@@ -474,7 +474,7 @@ func stripCommonPrefix(lines []string) {
         * Check for vertical "line of stars" and correct prefix accordingly.
         */
        lineOfStars := false
-       if i := strings.IndexByte(prefix, '*'); i >= 0 {
+       if i := strings.Index(prefix, "*"); i >= 0 {
                // Line of stars present.
                if i > 0 && prefix[i-1] == ' ' {
                        i-- // remove trailing blank from prefix so stars remain aligned
index 31945aae8d5c8f9d0fabcb6fe5447c1a72afbd5b..39791ec6d88440e8e5cd720759670ced78c2a0d2 100644 (file)
@@ -429,7 +429,7 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
        }
 
        // check for a quotient
-       sep := strings.IndexByte(s, '/')
+       sep := strings.Index(s, "/")
        if sep >= 0 {
                if _, ok := z.a.SetString(s[0:sep], 10); !ok {
                        return nil, false
@@ -443,7 +443,7 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
        }
 
        // check for a decimal point
-       sep = strings.IndexByte(s, '.')
+       sep = strings.Index(s, ".")
        // check for an exponent
        e := strings.IndexAny(s, "eE")
        var exp Int
index f566a8816f3e2d59ede8c368f021167d0898a5fb..8396c0a155b4cb33ba0009c158353936ea75b770 100644 (file)
@@ -18,7 +18,7 @@ import (
 // When any of the arguments result in a standard violation then
 // FormatMediaType returns the empty string.
 func FormatMediaType(t string, param map[string]string) string {
-       slash := strings.IndexByte(t, '/')
+       slash := strings.Index(t, "/")
        if slash == -1 {
                return ""
        }
@@ -91,7 +91,7 @@ func checkMediaTypeDisposition(s string) error {
 // The returned map, params, maps from the lowercase
 // attribute to the attribute value with its case preserved.
 func ParseMediaType(v string) (mediatype string, params map[string]string, err error) {
-       i := strings.IndexByte(v, ';')
+       i := strings.Index(v, ";")
        if i == -1 {
                i = len(v)
        }
@@ -127,7 +127,7 @@ func ParseMediaType(v string) (mediatype string, params map[string]string, err e
                }
 
                pmap := params
-               if idx := strings.IndexByte(key, '*'); idx != -1 {
+               if idx := strings.Index(key, "*"); idx != -1 {
                        baseName := key[:idx]
                        if continuation == nil {
                                continuation = make(map[string]map[string]string)
index 3a1ef529336fdaac2098e27e8a5817059527eaf9..100b8b77760e7db692a9d3026538824333d882db 100644 (file)
@@ -40,7 +40,7 @@ func Request() (*http.Request, error) {
 func envMap(env []string) map[string]string {
        m := make(map[string]string)
        for _, kv := range env {
-               if idx := strings.IndexByte(kv, '='); idx != -1 {
+               if idx := strings.Index(kv, "="); idx != -1 {
                        m[kv[:idx]] = kv[idx+1:]
                }
        }
index c72c3a21dbc2e35b7b56450cb7070fb7364db74c..540a8f7a9a18c19ada3580409c65481ced2325af 100644 (file)
@@ -47,7 +47,7 @@ func readSetCookies(h Header) []*Cookie {
                        continue
                }
                parts[0] = strings.TrimSpace(parts[0])
-               j := strings.IndexByte(parts[0], '=')
+               j := strings.Index(parts[0], "=")
                if j < 0 {
                        continue
                }
@@ -71,7 +71,7 @@ func readSetCookies(h Header) []*Cookie {
                        }
 
                        attr, val := parts[i], ""
-                       if j := strings.IndexByte(attr, '='); j >= 0 {
+                       if j := strings.Index(attr, "="); j >= 0 {
                                attr, val = attr[:j], attr[j+1:]
                        }
                        lowerAttr := strings.ToLower(attr)
@@ -188,7 +188,7 @@ func readCookies(h Header, filter string) []*Cookie {
                                continue
                        }
                        name, val := parts[i], ""
-                       if j := strings.IndexByte(name, '='); j >= 0 {
+                       if j := strings.Index(name, "="); j >= 0 {
                                name, val = name[:j], name[j+1:]
                        }
                        if !isCookieNameValid(name) {
index dcc3bbcb6aaa7b30fb9d125e452304913e5da973..19b493c3755c5ec71692a8d8cbdf677330bbd407 100644 (file)
@@ -467,7 +467,7 @@ func parseRange(s string, size int64) ([]httpRange, error) {
                if ra == "" {
                        continue
                }
-               i := strings.IndexByte(ra, '-')
+               i := strings.Index(ra, "-")
                if i < 0 {
                        return nil, errors.New("invalid range")
                }
index 5d9adf70245fdf72168332f0e7e95cfbe65f17d8..90e56225dd4e3d8f2e731f9e148cf74dd88babf2 100644 (file)
@@ -408,7 +408,7 @@ func ParseHTTPVersion(vers string) (major, minor int, ok bool) {
        if !strings.HasPrefix(vers, "HTTP/") {
                return 0, 0, false
        }
-       dot := strings.IndexByte(vers, '.')
+       dot := strings.Index(vers, ".")
        if dot < 0 {
                return 0, 0, false
        }
@@ -473,8 +473,8 @@ func (r *Request) SetBasicAuth(username, password string) {
 
 // parseRequestLine parses "GET /foo HTTP/1.1" into its three parts.
 func parseRequestLine(line string) (method, requestURI, proto string, ok bool) {
-       s1 := strings.IndexByte(line, ' ')
-       s2 := strings.IndexByte(line[s1+1:], ' ')
+       s1 := strings.Index(line, " ")
+       s2 := strings.Index(line[s1+1:], " ")
        if s1 < 0 || s2 < 0 {
                return
        }
index 897697d139664ec218a8f2a848e917791a7fb6c5..4e8f6dce2e155749db93a912f1dd2f7ff9e4f48f 100644 (file)
@@ -1262,7 +1262,7 @@ func Redirect(w ResponseWriter, r *Request, urlStr string, code int) {
                        }
 
                        var query string
-                       if i := strings.IndexByte(urlStr, '?'); i != -1 {
+                       if i := strings.Index(urlStr, "?"); i != -1 {
                                urlStr, query = urlStr[:i], urlStr[i:]
                        }
 
@@ -1494,7 +1494,7 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) {
                if pattern[0] != '/' {
                        // In pattern, at least the last character is a '/', so
                        // strings.Index can't be -1.
-                       path = pattern[strings.IndexByte(pattern, '/'):]
+                       path = pattern[strings.Index(pattern, "/"):]
                }
                mux.m[pattern[0:n-1]] = muxEntry{h: RedirectHandler(path, StatusMovedPermanently), pattern: pattern}
        }
index 1bf5581a17364b9d68776011068b77b466ba9180..043fd485391fbf3089c78f098093d3443853322f 100644 (file)
@@ -421,7 +421,7 @@ func parseAuthority(authority string) (user *Userinfo, host string, err error) {
                return
        }
        userinfo, host := authority[:i], authority[i+1:]
-       if strings.IndexByte(userinfo, ':') < 0 {
+       if strings.Index(userinfo, ":") < 0 {
                if userinfo, err = unescape(userinfo, encodeUserPassword); err != nil {
                        return
                }
@@ -536,7 +536,7 @@ func parseQuery(m Values, query string) (err error) {
                        continue
                }
                value := ""
-               if i := strings.IndexByte(key, '='); i >= 0 {
+               if i := strings.Index(key, "="); i >= 0 {
                        key, value = key[:i], key[i+1:]
                }
                key, err1 := QueryUnescape(key)
index 8bdcec9cc089c709463496475a2d79a2da77ec96..09daa3f018c31e2333c99522bdb1b8ce4577a65e 100644 (file)
@@ -890,7 +890,7 @@ func TestHostname(t *testing.T) {
        }
        want := run(t, []string{"/bin/hostname"})
        if hostname != want {
-               i := strings.IndexByte(hostname, '.')
+               i := strings.Index(hostname, ".")
                if i < 0 || hostname[0:i] != want {
                        t.Errorf("Hostname() = %q, want %q", hostname, want)
                }
index e68a83f80ce760dc62bfb7c1de2d1b833cd97dc2..6095422638d67dc8d4e034b56f8198f91bdd5767 100644 (file)
@@ -105,7 +105,7 @@ func lookupUnix(uid int, username string, lookupByName bool) (*User, error) {
        // say: "It is expected to be a comma separated list of
        // personal data where the first item is the full name of the
        // user."
-       if i := strings.IndexByte(u.Name, ','); i >= 0 {
+       if i := strings.Index(u.Name, ","); i >= 0 {
                u.Name = u.Name[:i]
        }
        return u, nil
index d811303500fcb2ad4ca129a998d4f1fbc5d159a1..8154bf6025162104d2f205322a0a3a36fb8115b8 100644 (file)
@@ -43,7 +43,7 @@ Pattern:
                star, chunk, pattern = scanChunk(pattern)
                if star && chunk == "" {
                        // Trailing * matches rest of string unless it has a /.
-                       return strings.IndexByte(name, '/') < 0, nil
+                       return strings.Index(name, "/") < 0, nil
                }
                // Look for match at current position.
                t, ok, err := matchChunk(chunk, name)
index d7f5de01fd3b37b2e8b4196068a6faa13fbba8f9..555e06e826dd8a2ea8e22b48a36b6a98dcf48af6 100644 (file)
@@ -293,7 +293,7 @@ func parseResult(t *testing.T, file string, lineno int, res string) []int {
                                out[n] = -1
                                out[n+1] = -1
                        } else {
-                               k := strings.IndexByte(pair, '-')
+                               k := strings.Index(pair, "-")
                                if k < 0 {
                                        t.Fatalf("%s:%d: invalid pair %s", file, lineno, pair)
                                }
@@ -456,7 +456,7 @@ Reading:
                                continue Reading
                        }
                case ':':
-                       i := strings.IndexByte(flag[1:], ':')
+                       i := strings.Index(flag[1:], ":")
                        if i < 0 {
                                t.Logf("skip: %s", line)
                                continue Reading
index fb699bbdcfa28870cd6a2e87cb07ec318a567a7f..0046026eaebdcfe1c8ed14525c3c451ad07aa7aa 100644 (file)
@@ -429,7 +429,7 @@ func Match(pattern string, b []byte) (matched bool, err error) {
 // in Expand, so for instance $1 represents the text of the first submatch.
 func (re *Regexp) ReplaceAllString(src, repl string) string {
        n := 2
-       if strings.IndexByte(repl, '$') >= 0 {
+       if strings.Index(repl, "$") >= 0 {
                n = 2 * (re.numSubexp + 1)
        }
        b := re.replaceAll(nil, src, n, func(dst []byte, match []int) []byte {
@@ -753,7 +753,7 @@ func (re *Regexp) ExpandString(dst []byte, template string, src string, match []
 
 func (re *Regexp) expand(dst []byte, template string, bsrc []byte, src string, match []int) []byte {
        for len(template) > 0 {
-               i := strings.IndexByte(template, '$')
+               i := strings.Index(template, "$")
                if i < 0 {
                        break
                }
index 73ab45e0662cb182526e10c613d1a1531bbbecd3..e5ed08b23779270d00da66142fdbc128392c8b61 100644 (file)
@@ -616,7 +616,7 @@ func verifyRange(name string, inCategory Op, table *unicode.RangeTable) {
 }
 
 func parseScript(line string, scripts map[string][]Script) {
-       comment := strings.IndexByte(line, '#')
+       comment := strings.Index(line, "#")
        if comment >= 0 {
                line = line[0:comment]
        }