]> source.dussan.org Git - redmine.git/commitdiff
Replace String#gsub with faster String#tr (#29363).
authorGo MAEDA <maeda@farend.jp>
Sun, 12 Aug 2018 23:40:44 +0000 (23:40 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 12 Aug 2018 23:40:44 +0000 (23:40 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17469 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/sys_controller.rb
app/helpers/application_helper.rb
app/models/mailer.rb
app/models/query.rb
config/initializers/10-patches.rb
lib/redmine/mime_type.rb
lib/redmine/scm/adapters/bazaar_adapter.rb

index bd8238a6accbf1d04940ea74da00dc87bf80b32c..35886fc4e397119512829171adb6251ca1720e9b 100644 (file)
@@ -38,7 +38,7 @@ class SysController < ActionController::Base
       repository.safe_attributes = params[:repository]
       repository.project = project
       if repository.save
-        render :json => {repository.class.name.underscore.gsub('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201
+        render :json => {repository.class.name.underscore.tr('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201
       else
         head 422
       end
index b7d83803488c82da6536f75be627f8b2f3e427a4..58b98845486c8ab674e0bc7cc93daeda00c9f093 100644 (file)
@@ -512,7 +512,7 @@ module ApplicationHelper
   end
 
   def anchor(text)
-    text.to_s.gsub(' ', '_')
+    text.to_s.tr(' ', '_')
   end
 
   def html_hours(text)
index ba6a677575d3270f3a5d97421a18f3c5a2f38fd3..466ebe4672a98e5059986c9049b0568c3848dcef 100644 (file)
@@ -447,7 +447,7 @@ class Mailer < ActionMailer::Base
             'X-Auto-Response-Suppress' => 'All',
             'Auto-Submitted' => 'auto-generated',
             'From' => Setting.mail_from,
-            'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
+            'List-Id' => "<#{Setting.mail_from.to_s.tr('@', '.')}>"
 
     # Replaces users with their email addresses
     [:to, :cc, :bcc].each do |key|
index e32dda8650a18436e80b79eb1997dc60c4c2a772..fa5c926ba00c9c70bcd74efd074635761527231c 100644 (file)
@@ -880,7 +880,7 @@ class Query < ActiveRecord::Base
         filters_clauses << sql_for_custom_field(field, operator, v, $1)
       elsif field =~ /^cf_(\d+)\.(.+)$/
         filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2)
-      elsif respond_to?(method = "sql_for_#{field.gsub('.','_')}_field")
+      elsif respond_to?(method = "sql_for_#{field.tr('.','_')}_field")
         # specific statement
         filters_clauses << send(method, field, operator, v)
       else
index d4e1ae88985e03b41497921d0ffb2a5e4c5b8671..b5698b43629c7d67588e0f178f3d22895357b665 100644 (file)
@@ -6,7 +6,7 @@ module ActiveRecord
     # Translate attribute names for validation errors display
     def self.human_attribute_name(attr, options = {})
       prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
-      class_prefix = name.underscore.gsub('/', '_')
+      class_prefix = name.underscore.tr('/', '_')
 
       redmine_default = [
         :"field_#{class_prefix}_#{prepared_attr}",
index 090bc506e20de62b85e854004539e9134dfbc55b..4ff04664d607c0739f6e0143780e0e0b10a2438b 100644 (file)
@@ -77,7 +77,7 @@ module Redmine
     # the mime type of name
     def self.css_class_of(name)
       mime = of(name)
-      mime && mime.gsub('/', '-')
+      mime && mime.tr('/', '-')
     end
 
     def self.main_mimetype_of(name)
index dc293d24cb3e1914501c98e5c7e05c0ab760b169..30d8aa7212b3f14bb24887a8a2f833c2126a974c 100644 (file)
@@ -94,7 +94,7 @@ module Redmine
           cmd_args << "-r#{identifier.to_i}"
           cmd_args << bzr_target(path)
           scm_cmd(*cmd_args) do |io|
-            prefix_utf8 = "#{url}/#{path}".gsub('\\', '/')
+            prefix_utf8 = "#{url}/#{path}".tr('\\', '/')
             logger.debug "PREFIX: #{prefix_utf8}"
             prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8)
             prefix.force_encoding('ASCII-8BIT')