emcconville / google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps
Other
154 stars 40 forks source link

Flatten optimization #9

Closed DMeshkov-HORIS closed 10 years ago

DMeshkov-HORIS commented 10 years ago

Functional style is a bit faster here

emcconville commented 10 years ago

Thanks for the revision! I've merged your changes into the pu branch, and will probably tag a new release shortly. Please take a moment to look at the Polyline-Encoder project. It uses the RecursiveIteratorIterator for array flattening. Ideally both projects should match list/tuple optimization.

emcconville commented 10 years ago

Wow! Running benchmarks on large data sets, I'm seeing a consistently large performances improvement by up to 40x.

DMeshkov-HORIS commented 10 years ago

You`d better use iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($points)), false) if you want to use SPL, but they are both faster then current version of flatten on large data sets.