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

Resolve #1198: Fix FileChannel.read to have same semantics as JVM #1200

Merged
merged 3 commits into from Jul 3, 2018
Merged

Resolve #1198: Fix FileChannel.read to have same semantics as JVM #1200

merged 3 commits into from Jul 3, 2018

Conversation

dev-inigmas
Copy link

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.

Copy link
Member

@densh densh left a 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) {
Copy link
Member

@densh densh Mar 22, 2018

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
Copy link
Member

Choose a reason for hiding this comment

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

Ambiguous name wrt 🥖.

Copy link
Author

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.

Copy link
Member

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. 😃

@densh
Copy link
Member

densh commented Jul 3, 2018

LGTM, thanks @dlpatri! 👍

@densh densh merged commit b6901c8 into scala-native:master Jul 3, 2018
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.

None yet

3 participants