capstone-rust / capstone-rs

high-level Capstone system bindings for Rust
217 stars 75 forks source link

arch: Implement size_hint for operand iterators #102

Closed leoetlino closed 3 years ago

leoetlino commented 3 years ago

Noticed while profiling that vector resizing was pretty hot when disassembly and getting operands, and it appears to be due to operand iterators not implementing size_hint. We can simply delegate size_hint to the underlying iterator.

leoetlino commented 3 years ago

The test failures appear to be unrelated.

tmfink commented 3 years ago

Thanks for the PR! There may be some other places where we can do a better job of passing information we already know (like this).

My plan is to expose some of the data we have a slice instead (like @ExPixel has done in #82, #85). Then, we won't need to jump through these hoops to make sure that the iterators get optimized.