writeMapStringBool writes map[string]bool using chunk protocol When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
(buf *ByteBuffer, m map[string]bool, hasGenerics bool)
| 471 | // writeMapStringBool writes map[string]bool using chunk protocol |
| 472 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 473 | func writeMapStringBool(buf *ByteBuffer, m map[string]bool, hasGenerics bool) { |
| 474 | length := len(m) |
| 475 | buf.WriteVarUint32(uint32(length)) |
| 476 | if length == 0 { |
| 477 | return |
| 478 | } |
| 479 | |
| 480 | remaining := length |
| 481 | for remaining > 0 { |
| 482 | chunkSize := remaining |
| 483 | if chunkSize > MAX_CHUNK_SIZE { |
| 484 | chunkSize = MAX_CHUNK_SIZE |
| 485 | } |
| 486 | |
| 487 | if hasGenerics { |
| 488 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 489 | buf.WriteUint8(uint8(chunkSize)) |
| 490 | } else { |
| 491 | buf.WriteUint8(0) |
| 492 | buf.WriteUint8(uint8(chunkSize)) |
| 493 | buf.WriteUint8(uint8(STRING)) // key type |
| 494 | buf.WriteUint8(uint8(BOOL)) // value type |
| 495 | } |
| 496 | |
| 497 | count := 0 |
| 498 | for k, v := range m { |
| 499 | writeString(buf, k) |
| 500 | buf.WriteBool(v) |
| 501 | count++ |
| 502 | if count >= chunkSize { |
| 503 | break |
| 504 | } |
| 505 | } |
| 506 | remaining -= chunkSize |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | // readMapStringBool reads map[string]bool using chunk protocol |
| 511 | func readMapStringBool(ctx *ReadContext) map[string]bool { |
no test coverage detected