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

Adding Jsrt function JsCopyStringOneByte #3408

Merged

Conversation

MSLaguana
Copy link
Contributor

For scenarios where a string is known to have values fitting in
one byte, this method allows directly copying those values into a
char* buffer rather than having to copy to a uint16_t* buffer
and then to a char* buffer, and treating the string as raw bytes
rather than a valid utf8 encoding.

This will help reduce overhead in some common nodejs use cases.

@@ -679,5 +679,42 @@ CHAKRA_API
_In_ JsPropertyIdRef propertyId,
_Out_ bool *hasOwnProperty);

/// <summary>
/// Write JS string value into char string buffer without a null terminator
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some more details about the semantics of this API, specifically what happens if the codepoint being copied is not within the char range

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, that's great. Also clarify that UTF16 encoded codepoints are being truncated in this case. Actually, what happens in the case of a surrogate pair?

For scenarios where a string is known to have values fitting in
one byte, this method allows directly copying those values into a
char* buffer rather than having to copy to a uint16_t* buffer
and then to a char* buffer, and treating the string as raw bytes
rather than a valid utf8 encoding.
@chakrabot chakrabot merged commit 9020556 into chakra-core:release/1.7 Jul 21, 2017
chakrabot pushed a commit that referenced this pull request Jul 21, 2017
Merge pull request #3408 from MSLaguana:addJsrtOneByteStringCopy

For scenarios where a string is known to have values fitting in
one byte, this method allows directly copying those values into a
char* buffer rather than having to copy to a uint16_t* buffer
and then to a char* buffer, and treating the string as raw bytes
rather than a valid utf8 encoding.

This will help reduce overhead in some common nodejs use cases.
chakrabot pushed a commit that referenced this pull request Jul 21, 2017
…ngOneByte

Merge pull request #3408 from MSLaguana:addJsrtOneByteStringCopy

For scenarios where a string is known to have values fitting in
one byte, this method allows directly copying those values into a
char* buffer rather than having to copy to a uint16_t* buffer
and then to a char* buffer, and treating the string as raw bytes
rather than a valid utf8 encoding.

This will help reduce overhead in some common nodejs use cases.
@MSLaguana MSLaguana deleted the addJsrtOneByteStringCopy branch October 2, 2017 16:29
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.

4 participants