Skip to content

Commit 3c66554

Browse files
committed
Use bytes.Count to count the number of message fields
Not a huge improvement but an improvement nonetheless. ``` goos: darwin goarch: arm64 pkg: github.com/quickfixgo/quickfix │ old3 │ new3 │ │ sec/op │ sec/op vs base │ ParseMessage-8 680.6n ± 0% 650.0n ± 0% -4.49% (p=0.000 n=20) ``` Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
1 parent e3a2994 commit 3c66554

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)