| 3808 | } |
| 3809 | |
| 3810 | function decodeString(dict: DictRead, layout: LeafLayout, r: Reader): string { |
| 3811 | const slot = dictSlot(dict, layout.slot) |
| 3812 | const state = slot.state |
| 3813 | if (state === DICT_GAVE_UP) return r.readUtf8(r.end - r.pos) |
| 3814 | if (state === DICT_WATCHING) { |
| 3815 | const value = r.readUtf8(r.end - r.pos) |
| 3816 | dictWatch(slot, value) |
| 3817 | return value |
| 3818 | } |
| 3819 | const marker = r.uvarint() |
| 3820 | if ((marker & 1) === 1) { |
| 3821 | const ref = (marker - 1) / 2 |
| 3822 | const values = slot.values |
| 3823 | if (ref >= values.length) invalid("a dictionary reference", marker, r.options) |
| 3824 | return values[ref] |
| 3825 | } |
| 3826 | if (marker !== 0) invalid("a dictionary marker", marker, r.options) |
| 3827 | const value = r.readUtf8(r.end - r.pos) |
| 3828 | dictAdd(slot, value) |
| 3829 | return value |
| 3830 | } |
| 3831 | |
| 3832 | function encodeInterned(table: InternWrite, ctx: EncodeContext, layout: Layout, value: unknown, w: Writer) { |
| 3833 | if (!table.disabled) { |