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

Publish Segment.size and Segment.remainingCapacity #409

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

fzhinkin
Copy link
Collaborator

Fixes #408

*
* @sample kotlinx.io.samples.unsafe.UnsafeBufferOperationsSamples.readUleb128
*/
public val size: Int
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps, it should be Long.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But then both pos and limit have to be updated too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main issue here that these properties already leaked into users' projects, like Ktor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And the reason why we might need Long properties here is supporting MemorySegmented backed segments on JVM (and that's nowhere near).

Copy link
Contributor

Choose a reason for hiding this comment

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

MemorySegments can be sliced which should be a cheap operation. If one came in over 2^31 in length, it could be sliced into multiple segments.

@fzhinkin fzhinkin requested review from qwwdfsad and shanshin October 30, 2024 16:11
@fzhinkin fzhinkin linked an issue Oct 30, 2024 that may be closed by this pull request
@fzhinkin fzhinkin merged commit e856d57 into develop Nov 6, 2024
1 check passed
@fzhinkin fzhinkin deleted the 408-make-segment-properties-public branch November 6, 2024 14:30
Egorand added a commit to Egorand/kotlinx-io that referenced this pull request Nov 14, 2024
* 'develop' of github.com:Kotlin/kotlinx-io:
  Publish Segment.size and Segment.remainingCapacity (Kotlin#409)
  Generate JPMS modules (Kotlin#406)
  Document empty bytestring factory (Kotlin#396)
  Update error message in `writableSegment` (Kotlin#398)
  Improve documentation (Kotlin#395)
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.

Unsafe API: make segment size and remaining capacity public
4 participants