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

feat(serde_v8): StringOrBuffer #12503

Merged
merged 4 commits into from
Oct 20, 2021

Conversation

AaronO
Copy link
Contributor

@AaronO AaronO commented Oct 20, 2021

Deserializes ArrayBufferViews to Vec<u8> when using deserialize_any (e.g: untagged serde enums)

Implements StringOrBuffer type for optimizations like #12451 (encoding the strings directly in the op-layer during opcall thus avoiding a core.encode() call upfront)

Note: unlike ZeroCopyBuf, StringOrBuffer is read-only and copies/owns its data

Deserializes ArrayBufferViews to Vec<u8> when using deserialize_any (e.g: untagged serde enums)
similar to ByteString and ZeroCopyBuf types
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +137 to +144
ValueType::ArrayBufferView => {
v8::Local::<v8::ArrayBufferView>::try_from(self.input)
.and_then(|view| {
magic::zero_copy_buf::ZeroCopyBuf::try_new(self.scope, view)
})
.map_err(|_| Error::ExpectedInteger)
.and_then(|zb| visitor.visit_byte_buf(Vec::from(&*zb)))
}
Copy link
Member

Choose a reason for hiding this comment

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

Note: this is safe because it does a memcpy.

@AaronO AaronO merged commit 783b4da into denoland:main Oct 20, 2021
@AaronO AaronO deleted the feat/serde-v8-string-or-buffer branch October 20, 2021 13:40
hardfist pushed a commit to hardfist/deno that referenced this pull request Aug 7, 2024
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