Skip to content

New Buffer API backport to v4.x#7475

Closed
ChALkeR wants to merge 2 commits intonodejs:v4.xfrom
ChALkeR:buffer-v4.x
Closed

New Buffer API backport to v4.x#7475
ChALkeR wants to merge 2 commits intonodejs:v4.xfrom
ChALkeR:buffer-v4.x

Conversation

@ChALkeR
Copy link
Copy Markdown
Member

@ChALkeR ChALkeR commented Jun 29, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

buffer

Description of change

This backports the new Buffer.alloc(), Buffer.allocUnsafe(), Buffer.from(), and Buffer.allocUnsafeSlow() APIs for v4.

Note: some backported tests are disabled, but those are not related to the new API.

Important: Buffer.from(arrayBuffer[, byteOffset [, length]]) (as in 6.x) was not backported, I used Buffer.from(arrayBuffer) instead, that helped to significantly reduce the code changes.

Note that --zero-fill-buffers is not included here (see #5745 for that), also the encoding parameter for .fill() is not included.

Existing code changes are minor here, this is not invasive.

Only two changes in existing code:

  1. .fill('') now zero-fills,

  2. One call to Buffer(string, encoding) is replaced with Buffer.from.

    There is a typecheck in that code path, so the behaviour is identical. In fact it could be reverted back to Buffer(string, encoding) or even changed to fromString(string, encoding) — that would just affect the double checks.

All the other changes are additive, i.e. introduce new methods and don't change the existing ones.

I'm hoping that this and #5745 will make it into 4.5.0.

/cc @jasnell @nodejs/ctc @seishun

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buffer Issues and PRs related to the buffer subsystem. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants