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
Resolve #1198: Fix FileChannel.read to have same semantics as JVM #1200
Resolve #1198: Fix FileChannel.read to have same semantics as JVM #1200
Conversation
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.
See some comments below, thanks for having a look!
|
||
var bread: Long = 0 | ||
|
||
for (i <- start until number) { |
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.
Please use while loops instead of for comprehensions for performance-sensitive code.
buffers(start + i).put(dst) | ||
i += 1 | ||
|
||
var bread: Long = 0 |
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.
Ambiguous name wrt 🥖.
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.
Yeah, I thought it'd be a fun way to write bytesRead in way that enforces the correct reading of read (like "red", as opposed to "reed"). But I can change it.
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 looked at that too and said "what!". Then I figured maybe it was bytesRead
but given your other short names it seemed out of place. I liked the 🍞 icon though. 😃
LGTM, thanks @dlpatri! 👍 |
Scala-Native's FileChannel.read operations were only reading a Byte at a time. The JVM's reads from the
ByteBuffer.position() until ByteBuffer.limit()
or less, if there aren't that many bytes to read.Added/Changed/Fixed tests in FilesSuite and FileChannelSuite to accommodate the changes.