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

Delta Between Two Patch Sets: src/pkg/strings/strings.go

Issue 12214044: code review 12214044: strings: add IndexByte, for consistency with bytes package (Closed)
Left Patch Set: diff -r ae2811a38d8b https://go.googlecode.com/hg/ Created 11 years, 8 months ago
Right Patch Set: diff -r ed08d206a05c https://go.googlecode.com/hg/ Created 11 years, 8 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 strings implements simple functions to manipulate strings. 5 // Package strings implements simple functions to manipulate strings.
6 package strings 6 package strings
7 7
8 import ( 8 import (
9 "unicode" 9 "unicode"
10 "unicode/utf8" 10 "unicode/utf8"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 i++ 155 i++
156 if h == hashsep && s[i-n:i] == sep { 156 if h == hashsep && s[i-n:i] == sep {
157 return i - n 157 return i - n
158 } 158 }
159 } 159 }
160 return -1 160 return -1
161 } 161 }
162 162
163 // IndexByte returns the index of the first instance of c in s, or -1 if c is no t present in s. 163 // IndexByte returns the index of the first instance of c in s, or -1 if c is no t present in s.
164 func IndexByte(s string, c byte) int { 164 func IndexByte(s string, c byte) int {
165 // special case worth making fast
166 for i := 0; i < len(s); i++ { 165 for i := 0; i < len(s); i++ {
167 if s[i] == c { 166 if s[i] == c {
168 return i 167 return i
169 } 168 }
170 } 169 }
171 return -1 170 return -1
172 } 171 }
173 172
174 // LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s. 173 // LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
175 func LastIndex(s, sep string) int { 174 func LastIndex(s, sep string) int {
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 729 }
731 if r == tr { 730 if r == tr {
732 continue 731 continue
733 } 732 }
734 return false 733 return false
735 } 734 }
736 735
737 // One string is empty. Are both? 736 // One string is empty. Are both?
738 return s == t 737 return s == t
739 } 738 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

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