diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-10-28 00:13:08 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-10-28 00:13:08 -0700 |
commit | c5e73b897616049c613b0331dd53e88dbc9c1532 (patch) | |
tree | 15e013b08c1a73356bab0aee2cdfe7c727072352 /actionpack | |
parent | 0b2dd7afd9ee1dfe46506f9d745afb0a23e496ba (diff) | |
download | rails-c5e73b897616049c613b0331dd53e88dbc9c1532.tar.gz rails-c5e73b897616049c613b0331dd53e88dbc9c1532.tar.bz2 rails-c5e73b897616049c613b0331dd53e88dbc9c1532.zip |
Reduce TextTemplate cost for simple cases
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/text.rb | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index e85823d8db..c30897b32a 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -24,6 +24,7 @@ module Mime LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? } def self.[](type) + return type if type.is_a?(Type) Type.lookup_by_extension(type.to_s) end diff --git a/actionpack/lib/action_view/template/text.rb b/actionpack/lib/action_view/template/text.rb index f7d0df5ba0..fa8cfe506b 100644 --- a/actionpack/lib/action_view/template/text.rb +++ b/actionpack/lib/action_view/template/text.rb @@ -1,6 +1,8 @@ module ActionView #:nodoc: class TextTemplate < String #:nodoc: - def initialize(string, content_type = Mime[:html]) + HTML = Mime[:html] + + def initialize(string, content_type = HTML) super(string.to_s) @content_type = Mime[content_type] || content_type end |