aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--repo.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/repo.go b/repo.go
index 8df6fdf..457dadd 100644
--- a/repo.go
+++ b/repo.go
@@ -223,12 +223,25 @@ func hashChunks(chunks <-chan StoredChunk) (FingerprintMap, SketchMap) {
fingerprints[h] = c.Id()
sketch, _ := SketchChunk(c, 32, 3, 4)
for _, s := range sketch {
- sketches[s] = append(sketches[s], c.Id())
+ prev := sketches[s]
+ if contains(prev, c.Id()) {
+ continue
+ }
+ sketches[s] = append(prev, c.Id())
}
}
return fingerprints, sketches
}
+func contains(s []*ChunkId, id *ChunkId) bool {
+ for _, v := range s {
+ if v == id {
+ return true
+ }
+ }
+ return false
+}
+
func findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool) {
var similarChunks = make(map[ChunkId]int)
var max int