path to asset is insanely slow cause it is pluralizing the word "javascript" over and over and over and over again.

This commit is contained in:
Sam 2013-04-09 11:53:23 +10:00
parent 64eeb7f21e
commit 47fb99198a
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# perf fixes, review for each rails upgrade.
class ActionView::Helpers::AssetTagHelper::AssetIncludeTag
private
# pluralization is fairly expensive, and pluralizing the word javascript 400 times is pointless
def path_to_asset(source, options = {})
asset_paths.compute_public_path(source, pluralize_asset_name(asset_name), options.merge(:ext => extension))
end
def path_to_asset_source(source)
asset_paths.compute_source_path(source, pluralize_asset_name(asset_name), extension)
end
def pluralize_asset_name(asset_name)
@@pluralization_cache ||= {}
plural = @@pluralization_cache[asset_name] ||= asset_name.to_s.pluralize
end
end