writeMapInt32Int32 writes map[int32]int32 using chunk protocol When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
(buf *ByteBuffer, m map[int32]int32, hasGenerics bool)
| 560 | // writeMapInt32Int32 writes map[int32]int32 using chunk protocol |
| 561 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 562 | func writeMapInt32Int32(buf *ByteBuffer, m map[int32]int32, hasGenerics bool) { |
| 563 | length := len(m) |
| 564 | buf.WriteVarUint32(uint32(length)) |
| 565 | if length == 0 { |
| 566 | return |
| 567 | } |
| 568 | |
| 569 | remaining := length |
| 570 | for remaining > 0 { |
| 571 | chunkSize := remaining |
| 572 | if chunkSize > MAX_CHUNK_SIZE { |
| 573 | chunkSize = MAX_CHUNK_SIZE |
| 574 | } |
| 575 | |
| 576 | if hasGenerics { |
| 577 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 578 | buf.WriteUint8(uint8(chunkSize)) |
| 579 | } else { |
| 580 | buf.WriteUint8(0) |
| 581 | buf.WriteUint8(uint8(chunkSize)) |
| 582 | buf.WriteUint8(uint8(VARINT32)) // key type |
| 583 | buf.WriteUint8(uint8(VARINT32)) // value type |
| 584 | } |
| 585 | |
| 586 | count := 0 |
| 587 | for k, v := range m { |
| 588 | buf.WriteVarint32(k) |
| 589 | buf.WriteVarint32(v) |
| 590 | count++ |
| 591 | if count >= chunkSize { |
| 592 | break |
| 593 | } |
| 594 | } |
| 595 | remaining -= chunkSize |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | // readMapInt32Int32 reads map[int32]int32 using chunk protocol |
| 600 | func readMapInt32Int32(ctx *ReadContext) map[int32]int32 { |
no test coverage detected