[x] I've documented or updated the documentation of every API function and struct this PR changes.
[x] I've added tests that prove my fix is effective or that my feature works (if possible)
Detailed description
Using fixed size arrays for instruction bytes is very good for performance and simplicity but it has some drawbacks. It can not be used for achitectures with instructions longer than fixed size array for instruction bytes. But big arrays is not practical for architecutres with small instructions.
This patch changes cs_insn.bytes into an union of small fixed array for small instructions and a pointer to dynamically allocated memory for very long instructions.
The size of the fixed array is chosen to be 16 bytes based on x86 instruction lengths.
Your checklist for this pull request
Detailed description
Using fixed size arrays for instruction bytes is very good for performance and simplicity but it has some drawbacks. It can not be used for achitectures with instructions longer than fixed size array for instruction bytes. But big arrays is not practical for architecutres with small instructions.
This patch changes
cs_insn.bytes
into an union of small fixed array for small instructions and a pointer to dynamically allocated memory for very long instructions.The size of the fixed array is chosen to be 16 bytes based on x86 instruction lengths.
Benchmarks
old
is https://github.com/capstone-engine/capstone/pull/2367.libc.so
is a standard C library from my amd64 machine.If
bytes_arr
size is 8 bytes.Test plan
Update bindings and user software.
Closing issues
...