Skip to content

Commit ca43582

Browse files
committed
Tweak parser for 10% performance improvement
1 parent 3cbade6 commit ca43582

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

parser.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,24 @@ func ParseMessage(line string) (*Message, error) {
261261
}
262262

263263
if line[0] == '@' {
264-
split := strings.SplitN(line, " ", 2)
265-
if len(split) < 2 {
264+
loc := strings.Index(line, " ")
265+
if loc == -1 {
266266
return nil, ErrMissingDataAfterTags
267267
}
268268

269-
c.Tags = ParseTags(split[0][1:])
270-
line = split[1]
269+
c.Tags = ParseTags(line[1:loc])
270+
line = line[loc+1:]
271271
}
272272

273273
if line[0] == ':' {
274-
split := strings.SplitN(line, " ", 2)
275-
if len(split) < 2 {
274+
loc := strings.Index(line, " ")
275+
if loc == -1 {
276276
return nil, ErrMissingDataAfterPrefix
277277
}
278278

279279
// Parse the identity, if there was one
280-
c.Prefix = ParsePrefix(split[0][1:])
281-
line = split[1]
280+
c.Prefix = ParsePrefix(line[1:loc])
281+
line = line[loc+1:]
282282
}
283283

284284
// Split out the trailing then the rest of the args. Because

0 commit comments

Comments
 (0)