@@ -63,20 +63,11 @@ class MsgPackDeserializer {
63
63
return skipBytes (code & 0x1f );
64
64
}
65
65
66
- if ((code & 0xf0 ) == 0x90 ) {
67
- if (filter.allowArray ())
68
- return readArray (variant.toArray (), code & 0x0F , filter, nestingLimit);
69
- else
70
- return skipArray (code & 0x0F , filter, nestingLimit);
71
- }
66
+ if ((code & 0xf0 ) == 0x90 )
67
+ return readArray (variant, code & 0x0F , filter, nestingLimit);
72
68
73
- if ((code & 0xf0 ) == 0x80 ) {
74
- size_t size = code & 0x0F ;
75
- if (filter.allowObject ())
76
- return readObject (variant.toObject (), size, filter, nestingLimit);
77
- else
78
- return skipObject (size, filter, nestingLimit);
79
- }
69
+ if ((code & 0xf0 ) == 0x80 )
70
+ return readObject (variant, code & 0x0F , filter, nestingLimit);
80
71
81
72
switch (code) {
82
73
case 0xc0 :
@@ -180,28 +171,16 @@ class MsgPackDeserializer {
180
171
return skipString<uint32_t >();
181
172
182
173
case 0xdc :
183
- if (filter.allowArray ())
184
- return readArray<uint16_t >(variant.toArray (), filter, nestingLimit);
185
- else
186
- return skipArray<uint16_t >(filter, nestingLimit);
174
+ return readArray<uint16_t >(variant, filter, nestingLimit);
187
175
188
176
case 0xdd :
189
- if (filter.allowArray ())
190
- return readArray<uint32_t >(variant.toArray (), filter, nestingLimit);
191
- else
192
- return skipArray<uint32_t >(filter, nestingLimit);
177
+ return readArray<uint32_t >(variant, filter, nestingLimit);
193
178
194
179
case 0xde :
195
- if (filter.allowObject ())
196
- return readObject<uint16_t >(variant.toObject (), filter, nestingLimit);
197
- else
198
- return skipObject<uint16_t >(filter, nestingLimit);
180
+ return readObject<uint16_t >(variant, filter, nestingLimit);
199
181
200
182
case 0xdf :
201
- if (filter.allowObject ())
202
- return readObject<uint32_t >(variant.toObject (), filter, nestingLimit);
203
- else
204
- return skipObject<uint32_t >(filter, nestingLimit);
183
+ return readObject<uint32_t >(variant, filter, nestingLimit);
205
184
}
206
185
207
186
if (!filter.allowValue ()) {
@@ -380,12 +359,12 @@ class MsgPackDeserializer {
380
359
}
381
360
382
361
template <typename TSize, typename TFilter>
383
- bool readArray (CollectionData &array , TFilter filter,
362
+ bool readArray (VariantData &variant , TFilter filter,
384
363
NestingLimit nestingLimit) {
385
364
TSize size;
386
365
if (!readInteger (size))
387
366
return false ;
388
- return readArray (array , size, filter, nestingLimit);
367
+ return readArray (variant , size, filter, nestingLimit);
389
368
}
390
369
391
370
template <typename TSize, typename TFilter>
@@ -397,13 +376,19 @@ class MsgPackDeserializer {
397
376
}
398
377
399
378
template <typename TFilter>
400
- bool readArray (CollectionData &array , size_t n, TFilter filter,
379
+ bool readArray (VariantData &variant , size_t n, TFilter filter,
401
380
NestingLimit nestingLimit) {
402
381
if (nestingLimit.reached ()) {
403
382
_error = DeserializationError::TooDeep;
404
383
return false ;
405
384
}
406
385
386
+ if (!filter.allowArray ()) {
387
+ return skipArray (n, filter, nestingLimit);
388
+ }
389
+
390
+ CollectionData &array = variant.toArray ();
391
+
407
392
TFilter memberFilter = filter[0U ];
408
393
409
394
for (; n; --n) {
@@ -437,12 +422,12 @@ class MsgPackDeserializer {
437
422
}
438
423
439
424
template <typename TSize, typename TFilter>
440
- bool readObject (CollectionData &object , TFilter filter,
425
+ bool readObject (VariantData &variant , TFilter filter,
441
426
NestingLimit nestingLimit) {
442
427
TSize size;
443
428
if (!readInteger (size))
444
429
return false ;
445
- return readObject (object , size, filter, nestingLimit);
430
+ return readObject (variant , size, filter, nestingLimit);
446
431
}
447
432
448
433
template <typename TSize, typename TFilter>
@@ -454,13 +439,19 @@ class MsgPackDeserializer {
454
439
}
455
440
456
441
template <typename TFilter>
457
- bool readObject (CollectionData &object , size_t n, TFilter filter,
442
+ bool readObject (VariantData &variant , size_t n, TFilter filter,
458
443
NestingLimit nestingLimit) {
459
444
if (nestingLimit.reached ()) {
460
445
_error = DeserializationError::TooDeep;
461
446
return false ;
462
447
}
463
448
449
+ if (!filter.allowObject ()) {
450
+ return skipObject (n, filter, nestingLimit);
451
+ }
452
+
453
+ CollectionData &object = variant.toObject ();
454
+
464
455
for (; n; --n) {
465
456
if (!readKey ())
466
457
return false ;
0 commit comments