Yoast/wordpress-seo — pull request #1812 by vdwijngaert (2014-12-03 12:40:45+00:00)
Title: Huge performance gain for enrich_defaults()

When working with around 50 taxonomies, which is not that uncommon, I experienced an abnormal performance loss coming from the WPSEO title functionality. I narrowed it down all the way to `WPSEO_Option_Titles::enrich_defaults()`, in my particular setup it was being fired by the plugin around 25 times, to enrich the defaults for the `wpseo_titles` option (I'm still shaking from going through all that code!).

Looking into it a bit further, I discovered that the foreach loop going over my taxonomies (53) took between 0.1 and 0.2 sec to complete, each time the function was being called (see http://pastebin.com/hx4qM1ke). I noticed the translation function. Although it has the same outcome, it is being executed each and every iteration. So it can also be done only once outside of the loop. That is what I did and I got some [astonishing results](http://pastebin.com/KzUyDLxS).

I know the underlying problem probably lies with the handling of the translation (I have WPML installed), but when you have the choice to choose between executing a function 25 times in stead of 1325 times, the choice is fairly easy to make, I think.

Thanks!

Koen

*PS: I did the same for the post type archives, because.. what's the harm in some extra performance, right? :)*