Skip to content

Commit

Permalink
Track the total number of in and out streams
Browse files Browse the repository at this point in the history
Saves having to iterate over each coder to calculate the totals each
time.
  • Loading branch information
bodgit committed Apr 24, 2022
1 parent 7764f72 commit d9a8fe8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,16 @@ func readFolder(hr headerReader) (*folder, error) {
return nil, err
}

in, out := uint64(0), uint64(0)

f.coder = make([]*coder, coders)
for i := uint64(0); i < coders; i++ {
if f.coder[i], err = readCoder(hr); err != nil {
return nil, err
}
in += f.coder[i].in
out += f.coder[i].out
f.in += f.coder[i].in
f.out += f.coder[i].out
}

bindPairs := out - 1
bindPairs := f.out - 1

f.bindPair = make([]*bindPair, bindPairs)
for i := uint64(0); i < bindPairs; i++ {
Expand All @@ -405,11 +403,11 @@ func readFolder(hr headerReader) (*folder, error) {
}
}

f.packedStreams = in - bindPairs
f.packedStreams = f.in - bindPairs

if f.packedStreams == 1 {
f.packed = []uint64{}
for i := uint64(0); i < in; i++ {
for i := uint64(0); i < f.in; i++ {
if f.findInBindPair(i) == nil {
f.packed = append(f.packed, i)
}
Expand Down
1 change: 1 addition & 0 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type bindPair struct {
}

type folder struct {
in, out uint64
packedStreams uint64
coder []*coder
bindPair []*bindPair
Expand Down

0 comments on commit d9a8fe8

Please sign in to comment.