-
Notifications
You must be signed in to change notification settings - Fork 982
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
Conversation
c3d58d2
to
2c07145
Compare
a5f9336
to
9f98d5d
Compare
{ | ||
// 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
An improvement to the API and performance. Nice work @StormHub! 👍 |
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
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