fast.bend checks
raw source on the hub · import lawful-bytes@0.1.0.0/fast.bend as Fast
4 imports
import Base import lawful-words@0.1.0.0/defs.bend as W import ./defs.bend as D import ./bytes.bend as B
Definitions
def zb source · line 13 · raw
@+v:U32 -> U32
0x80 at each byte of v that is 0, exact at the lowest such byte (a byte above a 0 byte may be flagged too).
def rep source · line 17 · raw
@+c:U32 -> U32
c in all four bytes of a word.
def b2u source · line 20 · raw
@b:Bool -> U32
def bidx source · line 28 · raw
@+m:U32 -> U32
The place (0-3) of the lowest flagged byte of a nonzero mask.
def low source · line 36 · raw
@+i:U32 -> U32
The bytes of a word at or above byte i's place. The first word of a search sets the bytes below the start to 0xFF before the zero-byte test (not the flags after it): zb is exact only at its lowest zero byte, and a match below the start would otherwise borrow and flag the byte at the start (found by the proof agent: "A@BC" searched for 'A' from 1).
def words source · line 40 · raw
@+from:U32 -> @+to:U32 -> Nat
How many words hold bytes from .. to-1 (0 when to <= from).
def find.fin source · line 47 · raw
@+to:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, U32)
def find.go source · line 53 · raw
@n:Nat -> @z:Bool -> @r:Pair(Array<U32>, U32) -> @+wi:U32 -> @+m:U32 -> @+rc:U32 -> Pair(Array<U32>, U32)
m flags word wi's hits; z: m is 0; r holds word wi + 1; n counts the words left, wi's included. Answers the offset of the first hit, or 2^32 - 1.
def find.start source · line 66 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+from:U32 -> @+rc:U32 -> Pair(Array<U32>, U32)
def find.k source · line 73 · raw
@+len:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, U32)
def find source · line 78 · raw
@b:0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes -> @+from:U32 -> @+to:U32 -> @+c:U32 -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, U32)
The first index j with from <= j < to where byte j is c; to if none.
def find2.go source · line 82 · raw
@n:Nat -> @z:Bool -> @r:Pair(Array<U32>, U32) -> @+wi:U32 -> @+m:U32 -> @+r1:U32 -> @+r2:U32 -> Pair(Array<U32>, U32)
def find2.start source · line 95 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+from:U32 -> @+r1:U32 -> @+r2:U32 -> Pair(Array<U32>, U32)
def find2 source · line 103 · raw
@b:0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes -> @+from:U32 -> @+to:U32 -> @+c1:U32 -> @+c2:U32 -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, U32)
The first index j with from <= j < to where byte j is c1 or c2; to if none.
def append.words source · line 113 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+lo:U32 -> @dst:Array<U32> -> @+si:U32 -> @+di:U32 -> @+sh:Nat -> Pair(Array<U32>, Array<U32>)
n words to dst from word di on, taken from src's bytes at a shift of sh bits: lo is src word si, r holds word si + 1.
def append.fin source · line 122 · raw
@+dl:U32 -> @+sl:U32 -> @r:Pair(Array<U32>, Array<U32>) -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, 0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes)
def append.w source · line 126 · raw
@+dl:U32 -> @+n:U32 -> @+q:U32 -> @db:Array<U32> -> @+sl:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, 0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes)
def append.k source · line 132 · raw
@+n:U32 -> @+q:U32 -> @r:Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, 0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes) -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, 0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes)
dst's length is now a multiple of 4: n more bytes of src from q, a word at a time (up to 3 bytes past the new length are overwritten too).
def append source · line 141 · raw
@dst:0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes -> @src:0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes -> @+s:U32 -> @+n:U32 -> Pair(0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes, 0xc018b2b7a70e32edf065f462beb7dcfd/defs.Bytes)
dst with bytes s .. s+n-1 of src added at the end; src handed back. The first bytes, up to dst's next word boundary, go one at a time, the rest a word at a time.