Permalink
Browse files

Merge pull request #2302 from christos/performant_options_for_select

Improve performance and memory usage for options_for_select with Ruby 1.8
  • Loading branch information...
2 parents e13e25d + 74a450d commit 348cd238f8ec7ed3ca7f9e2d24a87e715c898dee @fxn fxn committed Jul 27, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -298,12 +298,12 @@ def options_for_select(container, selected = nil)
return container if String === container
selected, disabled = extract_selected_and_disabled(selected).map do | r |
- Array.wrap(r).map(&:to_s)
+ Array.wrap(r).map { |item| item.to_s }
end
container.map do |element|
html_attributes = option_html_attributes(element)
- text, value = option_text_and_value(element).map(&:to_s)
+ text, value = option_text_and_value(element).map { |item| item.to_s }
selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled)
%(<option value="#{ERB::Util.html_escape(value)}"#{selected_attribute}#{disabled_attribute}#{html_attributes}>#{ERB::Util.html_escape(text)}</option>)

0 comments on commit 348cd23

Please sign in to comment.