-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ByteBuffer docs issue: Does not dissuade users from using get*
#2469
Comments
Uh oh. So I was working on the hexdump helpers (#2475), and very much used |
The So if you wanted to loop over all the bytes, then you could either do
or via the
The fastest way to access the bytes wholesale is through unsafe land Your hex dumping stuff will be part of NIO itself so for you the |
As the hex dump PR is close to a wrap, I think I stumbled at this enough times to try and put up a PR. I'll start with #2468, that one seems to be smaller. |
ByteBuffer.get*
is very often abused/misused. For example, what I see a lot isbuf.getData(at: 0, length: buf.readableBytes)!
.Obviously the user should do
Data(buffer: buf)
here because it's nicer and shorter.But most importantly, the
at: 0
is actually wrong. We should very much dissuade users from doingget*
. They should doTargetType(buffer: buf)
orread*
. The docs don't say that.The text was updated successfully, but these errors were encountered: