| 232 | } |
| 233 | |
| 234 | void skip_map(ReadContext &ctx, const FieldType &field_type) { |
| 235 | // Read map length |
| 236 | uint64_t total_length = ctx.read_var_uint64(ctx.error()); |
| 237 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 238 | return; |
| 239 | } |
| 240 | if (total_length == 0) { |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | // get key and value types |
| 245 | FieldType key_type, value_type; |
| 246 | if (field_type.generics.size() >= 2) { |
| 247 | key_type = field_type.generics[0]; |
| 248 | value_type = field_type.generics[1]; |
| 249 | } else { |
| 250 | // Unknown types |
| 251 | key_type.set_type_id(static_cast<uint32_t>(TypeId::UNKNOWN)); |
| 252 | value_type.set_type_id(static_cast<uint32_t>(TypeId::UNKNOWN)); |
| 253 | } |
| 254 | |
| 255 | uint64_t read_count = 0; |
| 256 | while (read_count < total_length) { |
| 257 | uint8_t header = ctx.read_uint8(ctx.error()); |
| 258 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 259 | return; |
| 260 | } |
| 261 | |
| 262 | if ((header & MAP_KEY_NULL) && (header & MAP_VALUE_NULL)) { |
| 263 | ++read_count; |
| 264 | continue; |
| 265 | } |
| 266 | |
| 267 | if (header & MAP_KEY_NULL) { |
| 268 | bool value_track_ref = (header & MAP_TRACKING_VALUE_REF) != 0; |
| 269 | bool value_declared = (header & MAP_DECL_VALUE_TYPE) != 0; |
| 270 | bool has_value = consume_ref_flag(ctx, value_track_ref, false); |
| 271 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 272 | return; |
| 273 | } |
| 274 | const TypeInfo *value_type_info = nullptr; |
| 275 | if (has_value && !value_declared) { |
| 276 | value_type_info = ctx.read_any_type_info(ctx.error()); |
| 277 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 278 | return; |
| 279 | } |
| 280 | } |
| 281 | if (has_value) { |
| 282 | skip_schema_or_type_info(ctx, value_type, value_type_info); |
| 283 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 284 | return; |
| 285 | } |
| 286 | } |
| 287 | ++read_count; |
| 288 | continue; |
| 289 | } |
| 290 | |
| 291 | if (header & MAP_VALUE_NULL) { |
no test coverage detected