File tree Expand file tree Collapse file tree 2 files changed +14
-24
lines changed Expand file tree Collapse file tree 2 files changed +14
-24
lines changed Original file line number Diff line number Diff line change @@ -31,23 +31,18 @@ func Lines(s []byte) iter.Seq[[]byte] {
31
31
}
32
32
}
33
33
34
- // explodeSeq returns an iterator over the runes in s.
35
- func explodeSeq (s []byte , yield func ([]byte ) bool ) {
36
- for len (s ) > 0 {
37
- _ , size := utf8 .DecodeRune (s )
38
- if ! yield (s [:size :size ]) {
39
- return
40
- }
41
- s = s [size :]
42
- }
43
- }
44
-
45
34
// splitSeq is SplitSeq or SplitAfterSeq, configured by how many
46
35
// bytes of sep to include in the results (none or all).
47
36
func splitSeq (s , sep []byte , sepSave int ) iter.Seq [[]byte ] {
48
37
return func (yield func ([]byte ) bool ) {
49
38
if len (sep ) == 0 {
50
- explodeSeq (s , yield )
39
+ for len (s ) > 0 {
40
+ _ , size := utf8 .DecodeRune (s )
41
+ if ! yield (s [:size :size ]) {
42
+ return
43
+ }
44
+ s = s [size :]
45
+ }
51
46
return
52
47
}
53
48
for {
Original file line number Diff line number Diff line change @@ -31,23 +31,18 @@ func Lines(s string) iter.Seq[string] {
31
31
}
32
32
}
33
33
34
- // explodeSeq returns an iterator over the runes in s.
35
- func explodeSeq (s string , yield func (string ) bool ) {
36
- for len (s ) > 0 {
37
- _ , size := utf8 .DecodeRuneInString (s )
38
- if ! yield (s [:size ]) {
39
- return
40
- }
41
- s = s [size :]
42
- }
43
- }
44
-
45
34
// splitSeq is SplitSeq or SplitAfterSeq, configured by how many
46
35
// bytes of sep to include in the results (none or all).
47
36
func splitSeq (s , sep string , sepSave int ) iter.Seq [string ] {
48
37
return func (yield func (string ) bool ) {
49
38
if len (sep ) == 0 {
50
- explodeSeq (s , yield )
39
+ for len (s ) > 0 {
40
+ _ , size := utf8 .DecodeRuneInString (s )
41
+ if ! yield (s [:size ]) {
42
+ return
43
+ }
44
+ s = s [size :]
45
+ }
51
46
return
52
47
}
53
48
for {
You can’t perform that action at this time.
0 commit comments