From 4cf28bf0e92127e2fdc636e411fff043bb0c6e0f Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 31 Jan 2015 01:53:42 +1100 Subject: [PATCH] Deduplicate iplist range descriptions, saves another 2.8MB heap --- client.go | 6 ++++++ 1 file changed, 6 insertions(+) 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() -- 2.48.1