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

Reuse allcocated arrays #250

Closed
hgourvest opened this issue Jan 10, 2024 · 2 comments
Closed

Reuse allcocated arrays #250

hgourvest opened this issue Jan 10, 2024 · 2 comments

Comments

@hgourvest
Copy link

There's no function for writing to a ByteArray pre-allocated in the Source interface.
Such a function would allow us to be more efficient by reusing memory.

fun read(dest: ByteArray, startIndex: Int, endIndex: Int) {
...
}
@fzhinkin
Copy link
Collaborator

@hgourvest do you mean a function to access an array backing the source's buffer or a function to read data from a source into an array?

If the latter, then it's already there:

public fun Source.readTo(sink: ByteArray, startIndex: Int = 0, endIndex: Int = sink.size) {

@hgourvest
Copy link
Author

@fzhinkin Exactly, I totally missed this function. Thank you!

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

No branches or pull requests

2 participants