Skip to content

Commit

Permalink
Reduce CPU usage
Browse files Browse the repository at this point in the history
We take advantage of the fact that dnscache uses a single space
character to separte fields, allowing us to use the simpler `strings.Split`
function instead of `strings.Fields`. When tested on real data using the
`Timestamped` benchmark, there was a 2x speedup.
  • Loading branch information
droyo committed Aug 11, 2016
1 parent 3820585 commit 6e3b4b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (l *logReader) run() {
}
scanner := bufio.NewScanner(l.src)
for scanner.Scan() {
line := strings.Fields(scanner.Text())
line := strings.Split(scanner.Text(), " ")
if len(line) < 1 {
continue
}
Expand Down

0 comments on commit 6e3b4b2

Please sign in to comment.