From 7fc79bc7907ea53aead3ff8461daedaacbf1cd71 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 27 Jan 2016 17:58:26 -0800 Subject: [PATCH] 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. --- .../lib/action_dispatch/http/mime_type.rb | 22 ++++++++----------- 1 file 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