Mailbox.next() removes the first buffered element with buffer.removeFirst() at Sources/ARCP/Runtime/Mailbox.swift:36. Array.removeFirst() shifts the remaining elements, so draining a large backlog of envelopes becomes quadratic in the number of buffered messages. Mailbox sits on the client and runtime receive path, so this affects resume, subscriptions, and any bursty transport where messages arrive faster than logical consumers process them.
Fix prompt: Replace the array-front removal with an O(1) queue strategy. A simple head index with periodic compaction keeps the current dependency set unchanged, while adopting a deque type would also be appropriate if the package adds Swift Collections directly. Add a focused performance or behavior test that enqueues and drains a large number of envelopes without relying on repeated array shifting.
Mailbox.next()removes the first buffered element withbuffer.removeFirst()atSources/ARCP/Runtime/Mailbox.swift:36.Array.removeFirst()shifts the remaining elements, so draining a large backlog of envelopes becomes quadratic in the number of buffered messages.Mailboxsits on the client and runtime receive path, so this affects resume, subscriptions, and any bursty transport where messages arrive faster than logical consumers process them.Fix prompt: Replace the array-front removal with an O(1) queue strategy. A simple head index with periodic compaction keeps the current dependency set unchanged, while adopting a deque type would also be appropriate if the package adds Swift Collections directly. Add a focused performance or behavior test that enqueues and drains a large number of envelopes without relying on repeated array shifting.