(key string, hash map[string][]byte, options ...interface{})
| 473 | } |
| 474 | |
| 475 | func (enc *Encoder) tryWriteZipListHashMap(key string, hash map[string][]byte, options ...interface{}) (bool, error) { |
| 476 | if len(hash) > enc.hashZipListOpt.getMaxEntries() { |
| 477 | return false, nil |
| 478 | } |
| 479 | maxValue := enc.hashZipListOpt.getMaxValue() |
| 480 | for _, v := range hash { |
| 481 | if len(v) > maxValue { |
| 482 | return false, nil |
| 483 | } |
| 484 | } |
| 485 | err := enc.write([]byte{typeHashZipList}) |
| 486 | if err != nil { |
| 487 | return true, err |
| 488 | } |
| 489 | err = enc.writeString(key) |
| 490 | if err != nil { |
| 491 | return true, err |
| 492 | } |
| 493 | entries := make([]string, 0, len(hash)*2) |
| 494 | for k, v := range hash { |
| 495 | entries = append(entries, k, unsafeBytes2Str(v)) |
| 496 | } |
| 497 | err = enc.writeZipList(entries) |
| 498 | if err != nil { |
| 499 | return true, err |
| 500 | } |
| 501 | return true, nil |
| 502 | } |
no test coverage detected