Skip to content

Commit f69f9f9

Browse files
authored
Merge pull request #655 from sylr/parse2
Use bytes.Count to count the number of message fields
2 parents e92fa68 + 3c66554 commit f69f9f9

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

message.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,7 @@ func doParsing(mp *msgParser) (err error) {
187187
mp.msg.Trailer.Clear()
188188

189189
// Allocate expected message fields in one chunk.
190-
fieldCount := 0
191-
for _, b := range mp.rawBytes {
192-
if b == '\001' {
193-
fieldCount++
194-
}
195-
}
190+
fieldCount := bytes.Count(mp.rawBytes, []byte{'\001'})
196191
if fieldCount == 0 {
197192
return parseError{OrigError: fmt.Sprintf("No Fields detected in %s", string(mp.rawBytes))}
198193
}

0 commit comments

Comments
 (0)