Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary_stream: Simplify away a no-op TypedArray #3113

Closed
wants to merge 1 commit into from

Conversation

kainino0x
Copy link
Collaborator

I just noticed this while looking around for TypedArray allocations that could be cleaned up. The code here didn't match the intent. This change is a no-op, but maybe there is a bug to be fixed instead.

I only verified the unittests pass, so far, since I figured I should send this to you first.

Issue: None


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

@kainino0x kainino0x requested a review from ben-clayton October 30, 2023 23:19
buffer(): ArrayBufferLike {
return new Uint8Array(this.view.buffer, align(this.offset, 8)).buffer;
Copy link
Collaborator Author

@kainino0x kainino0x Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Uint8Array wraps a view around this.view.buffer. Uint8Array.buffer returns the underlying ArrayBuffer of the view. Therefore this was the same as simply this.view.buffer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was supposed to be new Uint8Array(this.view.buffer, 0, align(this.offset, 8)).buffer as in: truncate the array to the written size. I actually noticed this bug yesterday, as all the cached files are 33.6MB (!). Fortunately tar.gz does a good job removing all those 0's.

@github-actions
Copy link

Previews, as seen when this build job started (fd9212a):
Run tests | View tsdoc

@kainino0x kainino0x requested a review from zoddicus October 31, 2023 17:54
@kainino0x kainino0x closed this Oct 31, 2023
@kainino0x kainino0x deleted the binarystream-buffer branch October 31, 2023 20:39
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.

3 participants