def bytes.push

gralha-bytes@0.1.0.1 · bytes.bend:64

import gralha-bytes@0.1.0.1/bytes.bend as Bytes
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

64def bytes.push(bytes: Bytes, +v: U32) -> Bytes:
65  Bytes{bufTree, size, capacity} = bytes
66  +data = bufTree
67  +n = size
68  +cap = capacity
69  +grow = U32.is_eq(n, cap)
70  +newcap = U.choose(U32, grow, (cap * 2 : U32), cap)
71  Bytes{bytes.tree.set(U.choose(ByteTree, grow, ByteNode{data, ByteFlat{0}}, data), newcap, n, v), U32.inc(n), newcap}

Uses (8)

Used by (16)