From 09170e8f8d9f2daff2e7aa4390566b23c291ebe2 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 11 Feb 2020 16:13:37 +0100 Subject: [PATCH] Fix comments, speed up Signed-off-by: Knut Ahlers --- main.go | 19 ++++--------------- provider_hostFile.go | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 425e5ec..ed766a3 100644 --- a/main.go +++ b/main.go @@ -106,25 +106,14 @@ func main() { } func addIfNotExists(entries []entry, e entry) []entry { - var ( - found bool - out []entry - ) - - for _, pe := range entries { + for i, pe := range entries { if pe.Domain == e.Domain { - found = true - pe.Comment = strings.Join([]string{pe.Comment, e.Comment}, ", ") + entries[i].Comment = strings.Join([]string{pe.Comment, e.Comment}, ", ") + return entries } - - out = append(out, pe) } - if !found { - out = append(out, e) - } - - return out + return append(entries, e) } func cleanFromList(blacklist, whitelist []entry) []entry { diff --git a/provider_hostFile.go b/provider_hostFile.go index 0403037..20761fa 100644 --- a/provider_hostFile.go +++ b/provider_hostFile.go @@ -54,7 +54,7 @@ func (p providerHostFile) GetDomainList(d providerDefinition) ([]entry, error) { continue } - comment := fmt.Sprintf("From: %q", d.Name) + comment := fmt.Sprintf("%q", d.Name) if len(groups) == 3 && strings.Trim(groups[2], "#") != "" { comment = fmt.Sprintf("%s, Comment: %q", comment,