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

Update Buffer implementation #9

Merged
merged 12 commits into from
Jul 7, 2022
Merged

Update Buffer implementation #9

merged 12 commits into from
Jul 7, 2022

Conversation

e5l
Copy link
Member

@e5l e5l commented Jul 5, 2022

No description provided.

@e5l e5l requested a review from rsinukov July 5, 2022 12:56
@e5l e5l self-assigned this Jul 5, 2022
Copy link
Collaborator

@whyoleg whyoleg left a comment

Choose a reason for hiding this comment

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

Some comments :)

src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/jvmMain/kotlin/io/ktor/io/DirectByteBufferPool.kt Outdated Show resolved Hide resolved
src/jvmMain/kotlin/io/ktor/io/JvmBuffer.kt Show resolved Hide resolved
src/jvmMain/kotlin/io/ktor/io/JvmBuffer.kt Show resolved Hide resolved
src/jvmMain/kotlin/io/ktor/io/JvmBufferPool.kt Outdated Show resolved Hide resolved
src/jvmTest/kotlin/io/ktor/io/JvmBufferTest.kt Outdated Show resolved Hide resolved
@e5l
Copy link
Member Author

e5l commented Jul 5, 2022

@whyoleg, thanks for the review. Looks like all points are valid, will fix soon

@e5l e5l requested a review from whyoleg July 6, 2022 10:52
Copy link
Collaborator

@whyoleg whyoleg left a comment

Choose a reason for hiding this comment

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

Overall LGTM, with more or less minor remarks (small amount about design). In coming days will try to play with API a bit in scope of rsocket-kotlin frame/transport logic and may be will have some more feedback

src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/ByteArrayBuffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/ByteArrayBufferPool.kt Outdated Show resolved Hide resolved
@e5l e5l requested a review from qwwdfsad July 6, 2022 12:19
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/Buffer.kt Outdated Show resolved Hide resolved
writeIndex = 0
}

public operator fun Buffer.get(index: Int): Byte = getByteAt(index)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need these operators? how often are they used?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made these operations to mimic ByteArray.

src/commonMain/kotlin/io/ktor/io/BufferedBytesSource.kt Outdated Show resolved Hide resolved
src/commonMain/kotlin/io/ktor/io/ByteArrayBuffer.kt Outdated Show resolved Hide resolved
@e5l
Copy link
Member Author

e5l commented Jul 7, 2022

@rsinukov, @whyoleg
Implementing CompositeBuffer I faced that it also would be great to have a steal method:

/**
 * Create a new [Buffer] from current and replace all content of this buffer with empty.
**/
fun steal(): Buffer

This method is an alternative to having mutable buffer access and using it will be possible to avoid making copies.

Could you tell me if it's ok to have it and add in the current PR? Or I should create a new PR for the discussion.

@e5l e5l requested review from whyoleg and rsinukov July 7, 2022 09:32
@whyoleg
Copy link
Collaborator

whyoleg commented Jul 7, 2022

let's move it to next PR, it's already a lot of changes and comments in this PR

@e5l e5l changed the base branch from e5l/cleanup-structure to main July 7, 2022 10:40
@rsinukov
Copy link
Contributor

rsinukov commented Jul 7, 2022

I agree, let's have it in the next PR

@e5l e5l merged commit 0182c3d into main Jul 7, 2022
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.

3 participants