spree/spree — pull request #4579 by mtuckergd (2014-04-14 20:22:19+00:00)
Title: Fix n+1 query performance issues on TaxRate.match method

Modified Spree::TaxRate.match method to prevent n+1 queries, which were amplified by the fact that they were repeated in a select loop (specifically, repeated calls to order.tax_zone).
With a large # tax rates and zones defined, this made checkout transition from address to payment state run extremely slow. No functional changes result in this update; simply a performance improvement to existing code by caching the order.tax_zone result in a local variable and eager loading the tax rate relations.

I don't believe this change applies to 2-2-stable and up, but this does affect 2-0-stable and 2-1-stable. Only tested locally for 2-0-stable.