From 3b9b37dde785bbb979bcf90ecdbbdf966cb18419 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Mon, 7 Oct 2019 19:18:30 +0300
Subject: [PATCH] * filter: speed up parsing

---
 home/filter.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/home/filter.go b/home/filter.go
index 80e448ea..be60e2a3 100644
--- a/home/filter.go
+++ b/home/filter.go
@@ -312,15 +312,14 @@ func isPrintableText(data []byte) bool {
 
 // A helper function that parses filter contents and returns a number of rules and a filter name (if there's any)
 func parseFilterContents(contents []byte) (int, string) {
-	lines := strings.Split(string(contents), "\n")
+	data := string(contents)
 	rulesCount := 0
 	name := ""
 	seenTitle := false
 
 	// Count lines in the filter
-	for _, line := range lines {
-
-		line = strings.TrimSpace(line)
+	for len(data) != 0 {
+		line := SplitNext(&data, '\n')
 		if len(line) == 0 {
 			continue
 		}