georust / gpx

Rust read/write support for GPS Exchange Format (GPX)
https://crates.io/crates/gpx
MIT License
102 stars 46 forks source link

Some optimizations #27

Closed oherrala closed 4 years ago

oherrala commented 4 years ago

On my dummy benchmark (I parsed fuzzing corpus files) these optimizations improve performance total up to 23%.

There's two good performance increasing optimizations.

  1. Remove cloning as much as possible (commit 816531ed67dc6d4b8fb53d1f8a80ca6008e2e57a). This gave up to 17% improvement. I'm not really familiar with error-chain so I probably did something silly there.

  2. Replace .filter(p).nth(0) with .find(p) from iterators (commit af771b8e6043af7d6d087f2581207bfd4c3228cb). This caught me by surprise, but showed up to 9% improvement. This was suggested by Clippy, so kudos to them!