(idx Index, hashes []plumbing.Hash)
| 70 | } |
| 71 | |
| 72 | func (e *Encoder) prepare(idx Index, hashes []plumbing.Hash) (hashToIndex map[plumbing.Hash]uint32, fanout []uint32, extraEdgesCount uint32) { |
| 73 | // Sort the hashes and build our index |
| 74 | plumbing.HashesSort(hashes) |
| 75 | hashToIndex = make(map[plumbing.Hash]uint32) |
| 76 | fanout = make([]uint32, 256) |
| 77 | for i, hash := range hashes { |
| 78 | hashToIndex[hash] = uint32(i) |
| 79 | fanout[hash[0]]++ |
| 80 | } |
| 81 | |
| 82 | // Convert the fanout to cumulative values |
| 83 | for i := 1; i <= 0xff; i++ { |
| 84 | fanout[i] += fanout[i-1] |
| 85 | } |
| 86 | |
| 87 | // Find out if we will need extra edge table |
| 88 | for i := 0; i < len(hashes); i++ { |
| 89 | v, _ := idx.GetCommitDataByIndex(i) |
| 90 | if len(v.ParentHashes) > 2 { |
| 91 | extraEdgesCount += uint32(len(v.ParentHashes) - 1) |
| 92 | break |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | func (e *Encoder) encodeFileHeader(chunkCount int) (err error) { |
| 100 | if _, err = e.Write(commitFileSignature); err == nil { |
no test coverage detected