writeMapIntInt writes map[int]int using chunk protocol When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
(buf *ByteBuffer, m map[int]int, hasGenerics bool)
| 730 | // writeMapIntInt writes map[int]int using chunk protocol |
| 731 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 732 | func writeMapIntInt(buf *ByteBuffer, m map[int]int, hasGenerics bool) { |
| 733 | length := len(m) |
| 734 | buf.WriteVarUint32(uint32(length)) |
| 735 | if length == 0 { |
| 736 | return |
| 737 | } |
| 738 | |
| 739 | remaining := length |
| 740 | for remaining > 0 { |
| 741 | chunkSize := remaining |
| 742 | if chunkSize > MAX_CHUNK_SIZE { |
| 743 | chunkSize = MAX_CHUNK_SIZE |
| 744 | } |
| 745 | |
| 746 | if hasGenerics { |
| 747 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 748 | buf.WriteUint8(uint8(chunkSize)) |
| 749 | } else { |
| 750 | buf.WriteUint8(0) |
| 751 | buf.WriteUint8(uint8(chunkSize)) |
| 752 | buf.WriteUint8(uint8(VARINT64)) // key type (int serialized as varint64) |
| 753 | buf.WriteUint8(uint8(VARINT64)) // value type |
| 754 | } |
| 755 | |
| 756 | count := 0 |
| 757 | for k, v := range m { |
| 758 | buf.WriteVarint64(int64(k)) |
| 759 | buf.WriteVarint64(int64(v)) |
| 760 | count++ |
| 761 | if count >= chunkSize { |
| 762 | break |
| 763 | } |
| 764 | } |
| 765 | remaining -= chunkSize |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | // readMapIntInt reads map[int]int using chunk protocol |
| 770 | func readMapIntInt(ctx *ReadContext) map[int]int { |
no test coverage detected