File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ private struct BitstreamReader {
104104 guard numOps > 0 else { throw Error . invalidAbbrev }
105105
106106 var operands : [ Bitstream . Abbreviation . Operand ] = [ ]
107+ operands. reserveCapacity ( numOps)
107108 for i in 0 ..< numOps {
108109 operands. append ( try readAbbrevOp ( ) )
109110
@@ -156,7 +157,11 @@ private struct BitstreamReader {
156157 let lastOperand = abbrev. operands. last!
157158 let lastRegularOperandIndex : Int = abbrev. operands. endIndex - ( lastOperand. isPayload ? 1 : 0 )
158159
159- // Safety: `lastRegularOperandIndex` is always at least 1.
160+ // Safety: `lastRegularOperandIndex` is always at least 1. An abbreviation
161+ // is required by the format to contain at least one operand. If that last
162+ // operand is a payload (and thus we subtracted one from the total number of
163+ // operands above), then that must mean it is either a trailing array
164+ // or trailing blob. Both of these are preceded by their length field.
160165 let fields = UnsafeMutableBufferPointer< UInt64> . allocate( capacity: lastRegularOperandIndex - 1 )
161166 defer { fields. deallocate ( ) }
162167
You can’t perform that action at this time.
0 commit comments