-
Notifications
You must be signed in to change notification settings - Fork 56
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
[PR 5/5] Hide Segment::data #339
Conversation
1855228
to
0a163a5
Compare
767a2c4
to
2268737
Compare
val v = ( | ||
data[pos++] and 0xffL shl 56 | ||
or (data[pos++] and 0xffL shl 48) | ||
or (data[pos++] and 0xffL shl 40) |
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.
Maybe it's paranoia, but does it work at the same speed as
or (data[pos + 1] and 0xffL shl 40)
?
(there is no frequent updating of the field value)
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.
pos
here is a local variable defined few lines above, so the field will be updated only once, after all reads are done.
Anyway, I'll re-check how it works with explicit offsets and immutable base, the last time I tested it, there was no significant difference.
23aaaab
to
0a86a46
Compare
13703b7
to
c644452
Compare
This PR concludes unsafe-API-related changes by hiding the
Segment::data.
The change itself has nothing to do with unsafe API as it is now but ensures that direct internal data won't leak into the codebase.
The latter unlocks features like #331 and #239