aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-01-27 17:58:26 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-01-27 18:28:05 -0800
commit7fc79bc7907ea53aead3ff8461daedaacbf1cd71 (patch)
tree2e610a49b0c2f0b90b5aef78c39083291b427cf6 /actionpack
parentf7f59c2eb732e9cb26060058e0ccac7dc74f324c (diff)
downloadrails-7fc79bc7907ea53aead3ff8461daedaacbf1cd71.tar.gz
rails-7fc79bc7907ea53aead3ff8461daedaacbf1cd71.tar.bz2
rails-7fc79bc7907ea53aead3ff8461daedaacbf1cd71.zip
remove useless private methods
This commit refactors the private methods that were just aliases to [] to just directly use [] and cache the return values on the stack.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb22
1 files changed, 9 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index d953030139..4a57e04c3a 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -121,26 +121,30 @@ module Mime
# Take care of the broken text/xml entry by renaming or deleting it
if text_xml_idx && app_xml_idx
- app_xml(app_xml_idx).q = [text_xml(text_xml_idx).q, app_xml(app_xml_idx).q].max # set the q value to the max of the two
+ app_xml = self[app_xml_idx]
+ text_xml = self[text_xml_idx]
+
+ app_xml.q = [text_xml.q, app_xml.q].max # set the q value to the max of the two
if app_xml_idx > text_xml_idx # make sure app_xml is ahead of text_xml in the list
- exchange_xml_items(text_xml_idx, app_xml_idx)
+ self[app_xml_idx], self[text_xml_idx] = text_xml, app_xml
app_xml_idx, text_xml_idx = text_xml_idx, app_xml_idx
end
delete_at(text_xml_idx) # delete text_xml from the list
elsif text_xml_idx
- text_xml(text_xml_idx).name = Mime[:xml].to_s
+ self[text_xml_idx].name = Mime[:xml].to_s
end
# Look for more specific XML-based types and sort them ahead of app/xml
if app_xml_idx
+ app_xml = self[app_xml_idx]
idx = app_xml_idx
while idx < length
type = self[idx]
- break if type.q < app_xml(app_xml_idx).q
+ break if type.q < app_xml.q
if type.name.ends_with? '+xml'
- self[app_xml_idx], self[idx] = self[idx], app_xml(app_xml_idx)
+ self[app_xml_idx], self[idx] = self[idx], app_xml
app_xml_idx = idx
end
idx += 1
@@ -150,14 +154,6 @@ module Mime
map! { |i| Mime::Type.lookup(i.name) }.uniq!
to_a
end
-
- private
- alias :text_xml :[]
- alias :app_xml :[]
-
- def exchange_xml_items(text_xml_idx, app_xml_idx)
- self[app_xml_idx], self[text_xml_idx] = text_xml(text_xml_idx), app_xml(app_xml_idx)
- end
end
class << self