Jim Lindley Notes

Optimized Route Generation

September 8th, 2007

A patch has just been applied to trunk (Changeset #7421), which can increase efficiency of url generation helpers by an order of magnitude. In order to take advantage of the optimization, you must make sure of the following:

  • Use a named route: (post_url, logout_url, etc)
  • The route definition must not have any :requirements
  • All arguments must be passed to the helper (do not rely on url defaults)

If those conditions are all met, the url can be generated via string interpolation - a vast speedup. The optimization happens on a per-link basis, you do not need to make sure all your routes and url helper calls fit the requirements above, keep using shortcuts and requirements where it makes sense.

Sorry, comments are closed for this article.