Skip to content

Adding Jsrt function JsCopyStringOneByte - #3408

Merged
chakrabot merged 1 commit into
chakra-core:release/1.7from
MSLaguana:addJsrtOneByteStringCopy
Jul 21, 2017
Merged

chakrabot merged 1 commit into
chakra-core:release/1.7from
MSLaguana:addJsrtOneByteStringCopy

Conversation

@MSLaguana

Copy link
Copy Markdown
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.

Comment thread lib/Jsrt/ChakraCore.h
_Out_ bool *hasOwnProperty);

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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.
@MSLaguana
MSLaguana force-pushed the addJsrtOneByteStringCopy branch from 1a36fd6 to 9020556 Compare July 21, 2017 15:36
@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