Skip to content

IO::Buffer: add #slice and #resize - #477

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster47
Aug 28, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster47

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Follow-up to the initial IO::Buffer, adding the two deferred memory operations:

  • slice(offset = 0, length = size - offset) returns a buffer sharing this
    buffer's memory over the range, so a write through the slice shows in the
    original. It inherits the read-only flag, reports as neither internal nor
    external (it owns no allocation), and can itself be resized; an out-of-range
    range raises ArgumentError.
  • resize(size) reallocates, preserving the leading bytes (a larger buffer is
    zero-filled) and marking the buffer internal; an external buffer (.for /
    .string) cannot be resized and raises AccessError.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 15890 → 15905 (core/io/buffer resize +7 plus
slice/internal/external, +17 aggregate, zero regressions in a per-file sweep).

🤖 Generated with Claude Code

Follow-up to the initial IO::Buffer, adding the two deferred memory operations:

- slice(offset = 0, length = size - offset) returns a buffer sharing this
  buffer's memory over the range, so a write through the slice shows in the
  original. It inherits the read-only flag, reports as neither internal nor
  external (it owns no allocation), and can itself be resized; an out-of-range
  range raises ArgumentError.
- resize(size) reallocates, preserving the leading bytes (a larger buffer is
  zero-filled) and marking the buffer internal; an external buffer (.for /
  .string) cannot be resized and raises AccessError.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
floor rises 15890 -> 15905 (core/io/buffer resize +7 plus slice/internal/external).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit b1c6c3e into main Aug 28, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster47 branch August 28, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant