aboutsummaryrefslogtreecommitdiffstats
path: root/skate/zippy.go
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-01 01:25:27 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-01 01:25:33 +0200
commitbd2dc54e9c56a260491acb5e77b4732563c58642 (patch)
tree6f1fde40f64b875b48161001558850218f409e0a /skate/zippy.go
parentf9515d2ece7d930481f11ba94ce08b9bc63e9a90 (diff)
downloadrefcat-bd2dc54e9c56a260491acb5e77b4732563c58642.tar.gz
refcat-bd2dc54e9c56a260491acb5e77b4732563c58642.zip
more effecient deduplicateBrefs
Diffstat (limited to 'skate/zippy.go')
-rw-r--r--skate/zippy.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/skate/zippy.go b/skate/zippy.go
index 59951e2..02d0428 100644
--- a/skate/zippy.go
+++ b/skate/zippy.go
@@ -408,19 +408,20 @@ func deduplicateBrefs(brefs []*BiblioRef) []*BiblioRef {
}
})
var (
- unique []*BiblioRef
- seen = set.New()
- // i int
+ seen = set.New()
+ i int
)
for _, v := range brefs {
if seen.Contains(v.Key) {
continue
}
- unique = append(unique, v)
+ brefs[i] = v
+ i++
seen.Add(v.Key)
}
- log.Printf("trimmed brefs from %d to %d", len(brefs), len(unique))
- return unique
+ brefs = brefs[:i]
+ log.Printf("trimmed brefs from %d to %d", len(brefs), i)
+ return brefs
}
// matchedRefsExtend takes a set of (unique) biblioref docs and will emit that