This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -204,22 +204,22 @@ func (idx *MemoryIndex) genOffsetHash() error {
204
204
idx .offsetHash = make (map [int64 ]plumbing.Hash , count )
205
205
idx .offsetHashIsFull = true
206
206
207
- iter , err := idx .Entries ()
208
- if err != nil {
209
- return err
210
- }
211
-
212
- for {
213
- entry , err := iter .Next ()
214
- if err != nil {
215
- if err == io .EOF {
216
- return nil
207
+ var hash plumbing.Hash
208
+ i := uint32 (0 )
209
+ for firstLevel , fanoutValue := range idx .Fanout {
210
+ hashPos := idx .FanoutMapping [firstLevel ]
211
+ for secondLevel := uint32 (0 ); i < fanoutValue ; i ++ {
212
+ copy (hash [:], idx .Names [hashPos ][secondLevel * objectIDLength :])
213
+ if idx .FanoutMapping [hash [0 ]] != idx .FanoutMapping [firstLevel ] {
214
+ panic (firstLevel )
217
215
}
218
- return err
216
+ offset := int64 (idx .getOffset (idx .FanoutMapping [hash [0 ]], int (secondLevel )))
217
+ idx .offsetHash [offset ] = hash
218
+ secondLevel ++
219
219
}
220
-
221
- idx .offsetHash [int64 (entry .Offset )] = entry .Hash
222
220
}
221
+
222
+ return nil
223
223
}
224
224
225
225
// Count implements the Index interface.
You can’t perform that action at this time.
0 commit comments