Repository navigation
fix(BufferStream): add only the bytes of a typed array view in addBuffer - #620
Merged
Merged
Conversation
SplitDataView.addBuffer replaced a typed array or DataView with its full underlying ArrayBuffer, and ignored byteOffset and byteLength. A small Node.js Buffer is a view of a shared pool, so ReadBufferStream.addBuffer and the ReadBufferStream constructor added bytes of other allocations. Fixes #619 Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ Deploy Preview for dcmjs2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
🎉 This PR is included in version 0.54.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change fixes #619 for the 0.52 releases.
SplitDataView.addBuffernow adds only the bytes of a typed array or aDataView, and not the full underlyingArrayBuffer.Problem
SplitDataView.addBufferreplaced the argument withbuffer.buffer, and ignoredbyteOffsetandbyteLength.ReadBufferStream.addBufferand theReadBufferStreamconstructor call this method. A small Node.jsBufferis a view of a shared pool. Thus each smallBufferadded the full pool, with the bytes of other allocations, to the stream.Changes
src/SplitDataView.js: for a view (ArrayBuffer.isView),addBufferusesbyteOffsetas the base.options.startandoptions.endare relative to the start of the view. When the view covers its fullArrayBuffer, the method transfers theArrayBufferas before. Otherwise it copies the bytes of the view.ArrayBufferargument has the same behaviour as before.test/readBufferStream.test.js: two tests ("the API must do this"):addBufferwith aUint8Arrayview and aDataViewof a largerArrayBufferadds only the bytes of each view.Compatibility
Before this change,
options.startandoptions.endfor a view were relative to the underlyingArrayBuffer. No caller in dcmjs gives a view together with these options. A caller outside dcmjs that gives a view withstartandendmust now give values relative to the view.Tests
Without the change in
src/SplitDataView.js, the two new tests fail.npm testreports 3 failures intest/data.test.js(test_multiframe_1,test_oneslice_seg,test_deflated). The same 3 tests also fail onmasterwithout this change on my system.A separate pull request makes the same fix on the
1.0-betabranch.🤖 Generated with Claude Code