Skip to content

Manticore\Ds: non-owning subarray views over a shared buffer #272

Open

Description

@blacktrs

Problem

A Manticore\Ds\ByteBuffer slice today is a copy (toString($offset, $length)). Code that carves a packet into fields and hands each to a callee pays an allocation and a copy per field.

Proposal

Non-owning subarray views over a shared buffer: $buf->view($offset, $length) returning a typed array that reads and writes through to the parent's bytes. Needs a lifetime rule (the view keeps the parent buffer alive) and a decision on parent growth (setSize / push reallocates the data pointer).

Status

No consumer in the repo. prelude/websocket.php and Http\ use Buffer\ByteBuffer (string + cursor), a different class, and the payload leaves the parser as a string anyway. The measurable cost on that path is applyMask, tracked separately. Build this when a concrete parser needs it.

Split out of #101 (part 6).

Activity

  1. added
    enhancement
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions