diff options
author | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-06-03 13:20:19 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-06-03 13:50:01 -0400 |
commit | 65760565fd8b6d72f7a31bfe8ffda4386fc8d8de (patch) | |
tree | 0261a9196a63f01b579a2b7436fe6aa23ad93b6c /go | |
parent | a4587d50708a73b65089c87e17523fac92d0249a (diff) |
cow-dedupe: Choose fiemap with fewest extents AND the most files
Diffstat (limited to 'go')
-rw-r--r-- | go/src/cow-dedupe/dedupe.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go index bc543f1..742cd60 100644 --- a/go/src/cow-dedupe/dedupe.go +++ b/go/src/cow-dedupe/dedupe.go @@ -254,14 +254,18 @@ func main() { for _, filename := range filenames { fiemaps = append(fiemaps, filename2fiemap[filename]) } - // Now we choose the fiemap with the fewest extents + // Now we choose the fiemap with the fewest + // extents and the most files minFiemap := fiemaps[0] minFiemapLen := strings.Count(minFiemap, "\n") + minFiemapCnt := len(fiemap2filenames[minFiemap]) for _, fiemap := range fiemaps { fiemapLen := strings.Count(fiemap, "\n") - if fiemapLen < minFiemapLen { + fiemapCnt := len(fiemap2filenames[fiemap]) + if fiemapLen < minFiemapLen || (fiemapLen == minFiemapLen && fiemapCnt > minFiemapCnt) { minFiemap = fiemap minFiemapLen = fiemapLen + minFiemapCnt = fiemapCnt } } // Set srcFile and dupFiles based on that |