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

[Rust] Offer a way to memcpy slices of integers to the destination #8449

Open
mstange opened this issue Dec 12, 2024 · 0 comments
Open

[Rust] Offer a way to memcpy slices of integers to the destination #8449

mstange opened this issue Dec 12, 2024 · 0 comments

Comments

@mstange
Copy link

mstange commented Dec 12, 2024

use flexbuffers::Builder;
let mut builder = Builder::default();
let mut root = builder.start_map();
root.push("my_ints", &[1i32, 2, 3, 4, 5]);
root.end_map();
write_to_file(builder.view());

Here, pushing the &[i32] iterates over all integers in the slice, finds the minimal width that's needed to represent all values, converts all values to that size, and writes them as little-endian.

Is there a more efficient way which boils down to a memcpy? My slices are very large and I would like to write them to the destination buffer as fast as possible. I don't mind if the stored representation isn't as compact as it could be.

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

1 participant