Skip to content

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

@Wyverex42

Description

@Wyverex42

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions