comfy/comfortable-mexican-sofa — pull request #337 by adammathys (2013-08-16 17:11:58+00:00)
Title: Split out the functionality of cms_page_content.

cms_page_content was very slow due to having to determine the type of content it was tasked with retrieving. Furthermore, the method would behave differently based on what content was being fetched. As such, it wasn't much of a stretch to split the method into two distinct methods.

Here are some benchmarks I hastily threw together to demonstrate the issue we encountered. On the left, is the improved time using the simplified `cms_page_block_content`. On the right, the original `cms_page_content`. These tests are from a single call to fetch a title attribute on a page.

```ruby
10.times { puts Benchmark.realtime { cms_page_block_content(:title, page) }}
10.times { puts Benchmark.realtime { cms_page_content(:title, page) }}
```

`cms_page_block_content` | `cms_page_content`
--------------------------|:------------------------------
0.001983987 | 0.082126979
0.000932087 | 0.019158611
0.00088599 | 0.019236887
0.000915634 | 0.019011066
0.000876496 | 0.018797225
0.000875165 | 0.018484832
0.000876062 | 0.018826148
0.000731387 | 0.018377427
0.000420175 | 0.018929082
0.000453011 | 0.018578592

The performance hit comes from having to determine the tag type of the content. Anecdotally, this change dropped our rendering times for the homepage of our website from 1s to 120ms.