woothemes/woocommerce — pull request #2065 by GeertDD (2012-12-27 09:38:56+00:00)
Title: Optimization for woocommerce_change_term_counts()

If the original term count is zero, this means no published products are found for the category or tag. In that case the custom WooCommerce product count, stored as term meta, will always be zero too. The custom product count just takes into account catalog visibility, but the first condition is for the product to be published.

Since the `woocommerce_change_term_counts()` functions is hooked to the `get_terms` filter, it is important to optimize. The `get_woocommerce_term_meta()` would be called for each product category or tag, which generates one extra database query per term.

I'd like to optimize it some more. Will come back to this later.