MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeInterned

Function decodeInterned

packages/effect/src/encoding/SchemaBinary.ts:4771–4796  ·  view source on GitHub ↗
(table: Array<unknown>, layout: Layout, r: Reader)

Source from the content-addressed store, hash-verified

4769type RunSlot = Field | null | undefined
4770
4771function decodeInterned(table: Array<unknown>, layout: Layout, r: Reader): unknown {
4772 const code = r.uvarint()
4773 if ((code & 1) === 1) {
4774 const ref = (code - 1) / 2
4775 if (ref >= table.length) invalid("a known back-reference", undefined, r.options)
4776 return table[ref]
4777 }
4778 // Plain strings consume their whole region, so they skip the reader window.
4779 if (layout._ === "string") {
4780 if (r.dict !== undefined) {
4781 const saved = r.enter(code / 2)
4782 const value = decodeChecked(layout, r)
4783 r.exit(saved)
4784 table.push(value)
4785 return value
4786 }
4787 const value = r.readUtf8(code / 2)
4788 table.push(value)
4789 return value
4790 }
4791 const saved = r.enter(code / 2)
4792 const value = decodeChecked(layout, r)
4793 r.exit(saved)
4794 table.push(value)
4795 return value
4796}
4797
4798function decodeStructRun(plan: RunPlan, count: number, r: Reader): Array<unknown> {
4799 const out: Array<unknown> = new Array(count)

Callers 1

decodeArrayFunction · 0.85

Calls 7

decodeCheckedFunction · 0.85
enterMethod · 0.80
exitMethod · 0.80
readUtf8Method · 0.80
invalidFunction · 0.70
pushMethod · 0.65
uvarintMethod · 0.45

Tested by

no test coverage detected