The first Living on the Edge covered some of the API changes since Rails 2.1, and this time round, I’m going to cover the performance improvements as promised.
Jumping right in…
Jeremy Kemper has made the Erb processing more efficient, especially the concat and capture helper methods.
The “special” Erb _erbout
has been replaced with an instance variable, which allows for:
s which are usually expensive,_erbout
variable when you can swap in a new (string) buffer, andoutput_buffer
reader and writer methods (so you can override it if you want).Relevant changesets: 933697a
- 0bdb7d3
- 4d4c8e2
Partial template initialization and JavaScript helpers have been refactored and optimized for speed and efficiency by Jeremy Kemper. These are but a few of the optimizations Jeremy has been committing recently. Be sure to check out some of the commits to Rails (or for that matter, any quality Open Source project) – you could learn something!
Relevant changesets: partials – JavaScript helpers
The RecordIdentifier has been sped up by some simple use of memo-ization, thus reducing the number of inflections performed, among other things. The RecordIdentifier is used widely in cache keys, partial template paths, and in most places where you identify an ActiveRecord model without caring about its actual id
.
Relevant changesets by Jeremy Kemper: c1a9820 – 566d717
Update: Oops my bad, this change was later reverted in 6573f6a.
The various cache stores in the ActiveSupport::Cache module are now lazy loaded – this means that they are only require
d when you actually start using them.