@@ -105,18 +105,21 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
105105 }
106106
107107 mutating func visitPackedFloatField( value: [ Float ] , fieldNumber: Int ) throws {
108+ assert ( !value. isEmpty)
108109 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
109110 let dataSize = value. count * MemoryLayout< Float> . size
110111 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
111112 }
112113
113114 mutating func visitPackedDoubleField( value: [ Double ] , fieldNumber: Int ) throws {
115+ assert ( !value. isEmpty)
114116 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
115117 let dataSize = value. count * MemoryLayout< Double> . size
116118 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
117119 }
118120
119121 mutating func visitPackedInt32Field( value: [ Int32 ] , fieldNumber: Int ) throws {
122+ assert ( !value. isEmpty)
120123 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
121124 var dataSize = 0
122125 for v in value {
@@ -127,6 +130,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
127130 }
128131
129132 mutating func visitPackedInt64Field( value: [ Int64 ] , fieldNumber: Int ) throws {
133+ assert ( !value. isEmpty)
130134 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
131135 var dataSize = 0
132136 for v in value {
@@ -137,6 +141,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
137141 }
138142
139143 mutating func visitPackedSInt32Field( value: [ Int32 ] , fieldNumber: Int ) throws {
144+ assert ( !value. isEmpty)
140145 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
141146 var dataSize = 0
142147 for v in value {
@@ -147,6 +152,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
147152 }
148153
149154 mutating func visitPackedSInt64Field( value: [ Int64 ] , fieldNumber: Int ) throws {
155+ assert ( !value. isEmpty)
150156 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
151157 var dataSize = 0
152158 for v in value {
@@ -157,6 +163,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
157163 }
158164
159165 mutating func visitPackedUInt32Field( value: [ UInt32 ] , fieldNumber: Int ) throws {
166+ assert ( !value. isEmpty)
160167 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
161168 var dataSize = 0
162169 for v in value {
@@ -167,6 +174,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
167174 }
168175
169176 mutating func visitPackedUInt64Field( value: [ UInt64 ] , fieldNumber: Int ) throws {
177+ assert ( !value. isEmpty)
170178 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
171179 var dataSize = 0
172180 for v in value {
@@ -177,30 +185,35 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
177185 }
178186
179187 mutating func visitPackedFixed32Field( value: [ UInt32 ] , fieldNumber: Int ) throws {
188+ assert ( !value. isEmpty)
180189 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
181190 let dataSize = value. count * MemoryLayout< UInt32> . size
182191 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
183192 }
184193
185194 mutating func visitPackedFixed64Field( value: [ UInt64 ] , fieldNumber: Int ) throws {
195+ assert ( !value. isEmpty)
186196 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
187197 let dataSize = value. count * MemoryLayout< UInt64> . size
188198 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
189199 }
190200
191201 mutating func visitPackedSFixed32Field( value: [ Int32 ] , fieldNumber: Int ) throws {
202+ assert ( !value. isEmpty)
192203 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
193204 let dataSize = value. count * MemoryLayout< Int32> . size
194205 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
195206 }
196207
197208 mutating func visitPackedSFixed64Field( value: [ Int64 ] , fieldNumber: Int ) throws {
209+ assert ( !value. isEmpty)
198210 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
199211 let dataSize = value. count * MemoryLayout< Int64> . size
200212 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
201213 }
202214
203215 mutating func visitPackedBoolField( value: [ Bool ] , fieldNumber: Int ) throws {
216+ assert ( !value. isEmpty)
204217 let tagSize = FieldTag ( fieldNumber: fieldNumber, wireFormat: . lengthDelimited) . encodedSize
205218 let dataSize = value. count
206219 serializedSize += tagSize + Varint. encodedSize ( of: Int64 ( dataSize) ) + dataSize
@@ -217,6 +230,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
217230
218231 mutating func visitRepeatedEnumField< E: Enum > ( value: [ E ] ,
219232 fieldNumber: Int ) throws {
233+ assert ( !value. isEmpty)
220234 let tagSize = FieldTag ( fieldNumber: fieldNumber,
221235 wireFormat: . varint) . encodedSize
222236 serializedSize += value. count * tagSize
@@ -228,6 +242,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
228242
229243 mutating func visitPackedEnumField< E: Enum > ( value: [ E ] ,
230244 fieldNumber: Int ) throws {
245+ assert ( !value. isEmpty)
231246 let tagSize = FieldTag ( fieldNumber: fieldNumber,
232247 wireFormat: . varint) . encodedSize
233248 serializedSize += tagSize
@@ -249,6 +264,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
249264
250265 mutating func visitRepeatedMessageField< M: Message > ( value: [ M ] ,
251266 fieldNumber: Int ) throws {
267+ assert ( !value. isEmpty)
252268 let tagSize = FieldTag ( fieldNumber: fieldNumber,
253269 wireFormat: . lengthDelimited) . encodedSize
254270 serializedSize += value. count * tagSize
@@ -270,6 +286,7 @@ internal struct BinaryEncodingSizeVisitor: Visitor {
270286
271287 mutating func visitRepeatedGroupField< G: Message > ( value: [ G ] ,
272288 fieldNumber: Int ) throws {
289+ assert ( !value. isEmpty)
273290 let tagSize = FieldTag ( fieldNumber: fieldNumber,
274291 wireFormat: . startGroup) . encodedSize
275292 serializedSize += 2 * value. count * tagSize
0 commit comments