Restructured filter for better performance #203
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was profiling my website and tracked back a performance issue to this function, this modification speeds up all my page loads by 0.2s (10%).
The site I work on is quite plugin heavy and presumably makes a lot of calls to get_post_metadata. This triggers this filter which in turn makes lots of fairly slow calls to get_option (which itself checks for several more filters and calls them).
I've re-ordered the function to greatly reduce the number of calls to get_option.
I'm afraid I don't actually know what this filter is for, however this change does not break/affect my website and the code certainly looks equivalent.
I'm sure that most websites don't have as many plugins or make as many calls to meta data. However, I'd very much appreciate it if you merged this change anyway, as I'm sure it will be useful to at least someone out there.
Keep up the good work on the plugin.
Kind regards and all the best,
Shanee Vanstone.