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

Remove buffer zeroing from Node.js implementation #315

Merged
merged 1 commit into from Oct 23, 2022
Merged

Conversation

josephlr
Copy link
Member

We can use Uint8Array::view_mut_raw which was added in version 0.2.54 of wasm-bindgen. This method was introduced to deal with uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey joerichey@google.com

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

Good find!

src/js.rs Outdated Show resolved Hide resolved
@@ -5,7 +5,7 @@
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::{util::uninit_slice_fill_zero, Error};
Copy link
Member

Choose a reason for hiding this comment

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

After this change, the only other place which uses uninit_slice_fill_zero is the custom backend. It could be worth to inline this function there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya I was going to clean this up when I cleaned up the custom implementation.

We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](rustwasm/wasm-bindgen#1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr merged commit 52a4c3c into master Oct 23, 2022
@josephlr josephlr deleted the js_zero branch October 23, 2022 23:22
@newpavlov newpavlov mentioned this pull request Apr 2, 2023
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.

None yet

2 participants