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

Why was read_bytes(char* ...) removed? #55

Open
Wyverex42 opened this issue Mar 25, 2023 · 1 comment
Open

Why was read_bytes(char* ...) removed? #55

Wyverex42 opened this issue Mar 25, 2023 · 1 comment

Comments

@Wyverex42
Copy link

I started using Kaitai two years ago when it was still version 0.8. After a long project hiatus I've now upgraded to 0.10 and noticed that the read_bytes(char*, std::streamsize) variant was removed. This is an issue for writing code that tries to avoid excessive memory allocations.

For the binary format I'm reading, Kaitai allocates a lot of small memory blocks and I ran into a "death by a thousand cuts" situation where parsing was extremely slow due to all those allocations. So I wrote a custom type that preallocated memory for certain regions of the file and parsing basically became instant.

Now that the char* variant of read_bytes was removed, I'm back to square one, unfortunately, and I can't avoid allocating memory when reading a block of bytes because I can only receive a new std::string instance as a return value.

Why was this decision made and could this be reversed?

Thank you!

@Wyverex42
Copy link
Author

Nvm, I just realized this function was never a part of this library in the first place and I added it myself precisely to avoid those allocations!

This might be a worthwhile addition to the interface.

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