Skip to content

Read and write chunks of memory for CString #17

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

Closed
nalenz-objectbox opened this issue Sep 11, 2019 · 6 comments
Closed

Read and write chunks of memory for CString #17

nalenz-objectbox opened this issue Sep 11, 2019 · 6 comments
Labels
good first issue Good for newcomers help wanted Looking for contributors (ideas, comments, code, etc)

Comments

@nalenz-objectbox
Copy link
Contributor

Currently, writing strings to and reading strings from memory is done character by character. Try to find a more efficient method to do that.

Is mostly related to CString (#7), but also memory chunks in general.

@vaind
Copy link
Contributor

vaind commented Sep 11, 2019

Dart FFI homepage links the following example:

Even though it still iterates, it looks less cumbersome than the current solution so maybe we could switch to that if there's no more efficient solution (consider opening an issue on dart github).

@Buggaboo
Copy link
Contributor

I tried looking for a way to read a C (contiguous?) memory block into a dart buffer(ish) type, but I haven't seen an appropiate ffi function for that. Reading and writing strings char by char does cost unnecessary cycles...

@vaind
Copy link
Contributor

vaind commented Sep 12, 2019

I think this dart issue covers our use case dart-lang/sdk#35762

@vaind
Copy link
Contributor

vaind commented Sep 12, 2019

And there's actually a new FFI utility package by the core team that could help us
https://github.com/dart-lang/ffi - https://pub.dev/packages/ffi

Utf8::fromUtf8 and Utf8::toUtf8 seem like a way to go. Ideally, we would remove our CString class completely, import the ffi package and use those functions.

@Buggaboo would you be willing to give it a shot?

@vaind vaind added good first issue Good for newcomers help wanted Looking for contributors (ideas, comments, code, etc) labels Sep 12, 2019
@Buggaboo
Copy link
Contributor

I'm on it

@vaind
Copy link
Contributor

vaind commented Sep 14, 2019

Thanks @Buggaboo for tackling this 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Looking for contributors (ideas, comments, code, etc)
Projects
None yet
Development

No branches or pull requests

3 participants