From afb92754c86372d34b36f8a3d340277c21a9c0e8 Mon Sep 17 00:00:00 2001 From: Alex Weidmann Date: Thu, 2 Oct 2014 17:35:13 -0600 Subject: [PATCH] Use #tr instead of #gsub where possible --- actionview/lib/action_view/helpers/form_tag_helper.rb | 2 +- actionview/lib/action_view/template.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 7d1cdc5a68..ff5d278b85 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -862,7 +862,7 @@ module ActionView # see http://www.w3.org/TR/html4/types.html#type-name def sanitize_to_id(name) - name.to_s.delete(']').gsub(/[^-a-zA-Z0-9:.]/, "_") + name.to_s.delete(']').tr('^-a-zA-Z0-9:.', "_") end end end diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index f398f9bfa3..379f31bdaf 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -321,7 +321,7 @@ module ActionView end def identifier_method_name #:nodoc: - inspect.gsub(/[^a-z_]/, '_') + inspect.tr('^a-z_', '_') end def instrument(action, &block)