-
Notifications
You must be signed in to change notification settings - Fork 321
Optimize unpackBinary #104
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
Conversation
…d fixed some errors
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.
We need to check offset + length <= arr.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.
Correct. I will fix this statement.
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.
How about checking here if the sum of offset + length doesn't exceed size?
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.
OK. If that test fails this code should throw IllegalArgumentException.
|
👍 |
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 think instanceof ByteArrayInputStream is not safe because in could be an instance of extended type of ByteArrayInputStream which overrides read(byte[]) method.
This is safe: ByteArrayInputStream.class.equals(in.getClass())
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.
That's true. We should compare the exact class type.
…fferBE.slice() to return big-endian buffer
Optimized
unpackBinaryby reducing the memory copy inMessageBufferInputimplementations.The other changes are as follows:
A performance report is in #103.