georust / rstar

R*-tree spatial index for the Rust ecosystem
https://docs.rs/rstar
Apache License 2.0
410 stars 68 forks source link

perf: minimize iterations over children in `IntersectionIterator` #110

Closed kylebarron closed 1 year ago

kylebarron commented 1 year ago

I was reading through the code and noticed that this was a double for loop, but children2 doesn't depend on child1 at all, so it doesn't need to be in the for loop. You do have to collect the items into a vector because you can't use the iterator more than once, but seems better than recomputing it every loop iteration?

urschrei commented 1 year ago

Lgtm!

urschrei commented 1 year ago

Bors r=adamreichold

bors[bot] commented 1 year ago

Build succeeded: