From 6e3b4b2f3c79634b0a81ca87150a100676b75ed1 Mon Sep 17 00:00:00 2001 From: David Arroyo Date: Wed, 10 Aug 2016 23:15:23 -0400 Subject: [PATCH] Reduce CPU usage 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. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7dbf7b0..9a2fd9e 100644 --- a/main.go +++ b/main.go @@ -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 }