Files
ww/lib
Hojun-Cho a6abac22d8 lib/bytes+test: Hare port (equal / index / rindex / contains / has{prefix,suffix} / reverse / zero)
Mirrors ref/hare/bytes/{equal,index,contains,reverse,zero}.ha for
the in-tree subset used by lib/encoding, lib/bufio, lib/memio;
converts 4 hextest sites from local beq to bytes.equal and drops
the now-dead beq in utf8test.

Surface:
  - equal(a, b: []u8) bool
  - index(s: []u8, needle: (u8 | []u8)) (i32 | void)
  - rindex(s: []u8, needle: (u8 | []u8)) (i32 | void)
  - contains(s: []u8, needle: (u8 | []u8)) bool
  - hasprefix(s, pre: []u8) bool
  - hassuffix(s, suf: []u8) bool
  - reverse(s: []u8) void  (already present, citation added)
  - zero(s: []u8) void  (already present, citation added)

Two documented Hare-fidelity gaps (cited in lib/bytes/bytes.ww
header, no in-tree caller demands them yet):
  - index_slice / rindex_slice use naive O(n·m). Hare specialises
    2/3/4-byte needles + falls back to Crochemore-Perrin two-way
    (ref/hare/bytes/two_way.ha). Correctness equivalent.
  - contains takes a single needle. Hare uses variadic
    needle: (u8 | []u8)... (ref/hare/bytes/contains.ha:5).

Tests: 967_bytes_run drives lib/bytes/bytestest.ww via ww run.
Eight @test fns × table-driven row sets: equal (5), index_byte
(5), index_slice (10), rindex_byte (3), rindex_slice (3),
contains (4), hasprefix (6 verbatim from contains.ha:25),
hassuffix (6 verbatim from contains.ha:40).

Call-site conversions in the same commit (the conversions are
the proof the API is wired): lib/encoding/hex/hextest.ww drops
the local beq helper and 4 callers switch to bytes.equal;
lib/encoding/utf8/utf8test.ww drops the dead beq helper.

91/91 ok. 995_self_rebuild stays green (ww2==ww3==ww4 byte-id).
2026-05-18 00:48:14 +09:00
..
2026-05-17 02:51:15 +09:00