Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(268)

Side by Side Diff: src/pkg/encoding/xml/xml.go

Issue 12486043: code review 12486043: all: use strings.IndexByte instead of Index where possible (Closed)
Patch Set: diff -r b2b6f8df031e https://go.googlecode.com/hg/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/encoding/xml/typeinfo.go ('k') | src/pkg/go/build/build.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package xml implements a simple XML 1.0 parser that 5 // Package xml implements a simple XML 1.0 parser that
6 // understands XML name spaces. 6 // understands XML name spaces.
7 package xml 7 package xml
8 8
9 // References: 9 // References:
10 // Annotated XML spec: http://www.xml.com/axml/testaxml.htm 10 // Annotated XML spec: http://www.xml.com/axml/testaxml.htm
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 r >= 0x10000 && r <= 0x10FFFF 1019 r >= 0x10000 && r <= 0x10FFFF
1020 } 1020 }
1021 1021
1022 // Get name space name: name with a : stuck in the middle. 1022 // Get name space name: name with a : stuck in the middle.
1023 // The part before the : is the name space identifier. 1023 // The part before the : is the name space identifier.
1024 func (d *Decoder) nsname() (name Name, ok bool) { 1024 func (d *Decoder) nsname() (name Name, ok bool) {
1025 s, ok := d.name() 1025 s, ok := d.name()
1026 if !ok { 1026 if !ok {
1027 return 1027 return
1028 } 1028 }
1029 » i := strings.Index(s, ":") 1029 » i := strings.IndexByte(s, ':')
1030 if i < 0 { 1030 if i < 0 {
1031 name.Local = s 1031 name.Local = s
1032 } else { 1032 } else {
1033 name.Space = s[0:i] 1033 name.Space = s[0:i]
1034 name.Local = s[i+1:] 1034 name.Local = s[i+1:]
1035 } 1035 }
1036 return name, true 1036 return name, true
1037 } 1037 }
1038 1038
1039 // Get name: /first(first|second)*/ 1039 // Get name: /first(first|second)*/
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 } 1800 }
1801 if v[0] != '\'' && v[0] != '"' { 1801 if v[0] != '\'' && v[0] != '"' {
1802 return "" 1802 return ""
1803 } 1803 }
1804 idx = strings.IndexRune(v[1:], rune(v[0])) 1804 idx = strings.IndexRune(v[1:], rune(v[0]))
1805 if idx == -1 { 1805 if idx == -1 {
1806 return "" 1806 return ""
1807 } 1807 }
1808 return v[1 : idx+1] 1808 return v[1 : idx+1]
1809 } 1809 }
OLDNEW
« no previous file with comments | « src/pkg/encoding/xml/typeinfo.go ('k') | src/pkg/go/build/build.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b