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

Buffer read/write/get/set strings. #369

Merged
merged 1 commit into from
Mar 15, 2018
Merged

Buffer read/write/get/set strings. #369

merged 1 commit into from
Mar 15, 2018

Conversation

StormHub
Copy link
Contributor

@StormHub StormHub commented Mar 7, 2018

Motivation:
Implement commonly used string-based operations (originally Netty CharSequence) for byte buffers.

Modifications:
Added read/write/get/set strings methods to byte buffers.
Also reduced unsafe pin/unpins for byte operations.

Result:
String-based operations are supported in DotNetty

@StormHub StormHub force-pushed the Work branch 4 times, most recently from c3d58d2 to 2c07145 Compare March 8, 2018 00:47
@StormHub StormHub force-pushed the Work branch 3 times, most recently from a5f9336 to 9f98d5d Compare March 15, 2018 03:49
{
// Surrogate Pair consumes 2 characters. Optimistically try to get the next character to avoid
// duplicate bounds checking with charAt. If an IndexOutOfBoundsException is thrown we will
// re-throw a more informative exception describing the problem.
Copy link
Member

Choose a reason for hiding this comment

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

where does this re-throwing happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, if that happens L316 will through buffer index out of range

Copy link
Member

Choose a reason for hiding this comment

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

sounds good

return writerIndex - oldWriterIndex;
}

public static int Utf8MaxBytes(string value) => Encoding.UTF8.GetMaxByteCount(value.Length);
Copy link
Member

@nayato nayato Mar 15, 2018

Choose a reason for hiding this comment

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

I'm ok with it if it's internal, not public. Let's not publish APIs unrelated to a subject (Buffer mgmt here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to internal, in netty it is public but that is for CharSequence, not string.

Motivation:
Implement commonly used string-based operations (originally Netty CharSequence) for byte buffers.

Modifications:
Added read/write/get/set strings methods to byte buffers.
Also reduced unsafe pin/unpins for byte operations.

Result:
String-based operations are supported in DotNetty
{
// Surrogate Pair consumes 2 characters. Optimistically try to get the next character to avoid
// duplicate bounds checking with charAt. If an IndexOutOfBoundsException is thrown we will
// re-throw a more informative exception describing the problem.
Copy link
Member

Choose a reason for hiding this comment

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

sounds good

@nayato nayato merged commit 33b95cf into Azure:dev Mar 15, 2018
@StormHub StormHub deleted the Work branch March 15, 2018 22:44
@alexmg
Copy link

alexmg commented Apr 6, 2018

An improvement to the API and performance. Nice work @StormHub! 👍

maksimkim pushed a commit to maksimkim/DotNetty that referenced this pull request Sep 14, 2019
Motivation:
Implement commonly used string-based operations (originally Netty CharSequence) for byte buffers.

Modifications:
Added read/write/get/set strings methods to byte buffers.
Also reduced unsafe pin/unpins for byte operations.

Result:
String-based operations are supported in DotNetty
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