mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
Taking the head entry of a Readable's buffer moved every remaining entry down one slot, so draining a queue of n buffered chunks cost O(n²). The buffer now keeps the index of its first entry: a take advances it, a push at the tail moves the entries down only when at least half the slots are free at the front (and grows otherwise), and unshift takes a freed front slot when there is one. The drop, trace and boxing loops walk the entries from that index. The stream-buffered-drain runtime workload buffers 200,000 objects and 100,000 Buffers before draining them; corpus 8533 covers reads across entries, unshift into a freed slot and onto a part-read head, setEncoding after takes, and object-mode takes, unshifts and pushes.