From: Matt Joiner Date: Fri, 30 Jan 2015 14:53:42 +0000 (+1100) Subject: Deduplicate iplist range descriptions, saves another 2.8MB heap X-Git-Tag: v1.0.0~1350 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4cf28bf0e92127e2fdc636e411fff043bb0c6e0f;p=btrtrc.git Deduplicate iplist range descriptions, saves another 2.8MB heap --- diff --git a/client.go b/client.go index 513e7871..cb66b565 100644 --- a/client.go +++ b/client.go @@ -345,6 +345,7 @@ func (cl *Client) setEnvBlocklist() (err error) { } defer f.Close() var ranges []iplist.Range + uniqStrs := make(map[string]string) scanner := bufio.NewScanner(f) for scanner.Scan() { r, ok, lineErr := iplist.ParseBlocklistP2PLine(scanner.Bytes()) @@ -355,6 +356,11 @@ func (cl *Client) setEnvBlocklist() (err error) { if !ok { continue } + if s, ok := uniqStrs[r.Description]; ok { + r.Description = s + } else { + uniqStrs[r.Description] = r.Description + } ranges = append(ranges, r) } err = scanner.Err()