()
| 107 | } |
| 108 | |
| 109 | func (p *ScodeEncoder) Dict() (PrimitiveEncoder, []byte, []uint32) { |
| 110 | m := make(map[string]byte) |
| 111 | var counts []uint32 |
| 112 | index := make([]byte, p.count) |
| 113 | entries := NewScodeEncoder(p.typ) |
| 114 | var k uint32 |
| 115 | it := p.bytes.Iter() |
| 116 | for !it.Done() { |
| 117 | v := it.Next() |
| 118 | tag, ok := m[string(v)] |
| 119 | if !ok { |
| 120 | tag = byte(len(counts)) |
| 121 | m[string(v)] = tag |
| 122 | counts = append(counts, 0) |
| 123 | entries.WriteBytes(v) |
| 124 | if len(counts) > math.MaxUint8 { |
| 125 | return nil, nil, nil |
| 126 | } |
| 127 | } |
| 128 | index[k] = tag |
| 129 | counts[tag]++ |
| 130 | k++ |
| 131 | } |
| 132 | return entries, index, counts |
| 133 | } |
| 134 | |
| 135 | func (p *ScodeEncoder) ConstValue() super.Value { |
| 136 | it := p.bytes.Iter() |
nothing calls this directly
no test coverage detected