MCPcopy Create free account
hub / github.com/bodgit/sevenzip / readBool

Function readBool

types.go:115–143  ·  view source on GitHub ↗
(r io.ByteReader, count uint64)

Source from the content-addressed store, hash-verified

113}
114
115func readBool(r io.ByteReader, count uint64) ([]bool, error) {
116 if err := checkUint64(count, true); err != nil {
117 return nil, err
118 }
119
120 // Preallocate with a maximum initial capacity of 1024 to prevent memory DoS
121 // on invalid high counts. Growth via append has negligible performance impact
122 // because 7z decompression CPU cycles dominate total execution time.
123 defined := make([]bool, 0, min(count, 1024))
124
125 var b, mask byte
126 for range count {
127 if mask == 0 {
128 var err error
129
130 b, err = r.ReadByte()
131 if err != nil {
132 return nil, fmt.Errorf("readBool: ReadByte error: %w", err)
133 }
134
135 mask = 0x80
136 }
137
138 defined = append(defined, (b&mask) != 0)
139 mask >>= 1
140 }
141
142 return defined, nil
143}
144
145func readOptionalBool(r io.ByteReader, count uint64) ([]bool, error) {
146 if err := checkUint64(count, true); err != nil {

Callers 2

readOptionalBoolFunction · 0.85
readFilesInfoFunction · 0.85

Calls 2

checkUint64Function · 0.85
ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…