Commit e52134a9 authored by maeda's avatar maeda

Replace String#gsub with faster String#tr (#29363).

Patch by Go MAEDA.


git-svn-id: https://svn.redmine.org/redmine/trunk@17469 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 93282b31
...@@ -38,7 +38,7 @@ class SysController < ActionController::Base ...@@ -38,7 +38,7 @@ class SysController < ActionController::Base
repository.safe_attributes = params[:repository] repository.safe_attributes = params[:repository]
repository.project = project repository.project = project
if repository.save 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 else
head 422 head 422
end end
......
...@@ -512,7 +512,7 @@ module ApplicationHelper ...@@ -512,7 +512,7 @@ module ApplicationHelper
end end
def anchor(text) def anchor(text)
text.to_s.gsub(' ', '_') text.to_s.tr(' ', '_')
end end
def html_hours(text) def html_hours(text)
......
...@@ -447,7 +447,7 @@ class Mailer < ActionMailer::Base ...@@ -447,7 +447,7 @@ class Mailer < ActionMailer::Base
'X-Auto-Response-Suppress' => 'All', 'X-Auto-Response-Suppress' => 'All',
'Auto-Submitted' => 'auto-generated', 'Auto-Submitted' => 'auto-generated',
'From' => Setting.mail_from, '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 # Replaces users with their email addresses
[:to, :cc, :bcc].each do |key| [:to, :cc, :bcc].each do |key|
......
...@@ -880,7 +880,7 @@ class Query < ActiveRecord::Base ...@@ -880,7 +880,7 @@ class Query < ActiveRecord::Base
filters_clauses << sql_for_custom_field(field, operator, v, $1) filters_clauses << sql_for_custom_field(field, operator, v, $1)
elsif field =~ /^cf_(\d+)\.(.+)$/ elsif field =~ /^cf_(\d+)\.(.+)$/
filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2) 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 # specific statement
filters_clauses << send(method, field, operator, v) filters_clauses << send(method, field, operator, v)
else else
......
...@@ -6,7 +6,7 @@ module ActiveRecord ...@@ -6,7 +6,7 @@ module ActiveRecord
# Translate attribute names for validation errors display # Translate attribute names for validation errors display
def self.human_attribute_name(attr, options = {}) def self.human_attribute_name(attr, options = {})
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '') prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
class_prefix = name.underscore.gsub('/', '_') class_prefix = name.underscore.tr('/', '_')
redmine_default = [ redmine_default = [
:"field_#{class_prefix}_#{prepared_attr}", :"field_#{class_prefix}_#{prepared_attr}",
......
...@@ -77,7 +77,7 @@ module Redmine ...@@ -77,7 +77,7 @@ module Redmine
# the mime type of name # the mime type of name
def self.css_class_of(name) def self.css_class_of(name)
mime = of(name) mime = of(name)
mime && mime.gsub('/', '-') mime && mime.tr('/', '-')
end end
def self.main_mimetype_of(name) def self.main_mimetype_of(name)
......
...@@ -94,7 +94,7 @@ module Redmine ...@@ -94,7 +94,7 @@ module Redmine
cmd_args << "-r#{identifier.to_i}" cmd_args << "-r#{identifier.to_i}"
cmd_args << bzr_target(path) cmd_args << bzr_target(path)
scm_cmd(*cmd_args) do |io| scm_cmd(*cmd_args) do |io|
prefix_utf8 = "#{url}/#{path}".gsub('\\', '/') prefix_utf8 = "#{url}/#{path}".tr('\\', '/')
logger.debug "PREFIX: #{prefix_utf8}" logger.debug "PREFIX: #{prefix_utf8}"
prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8) prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8)
prefix.force_encoding('ASCII-8BIT') prefix.force_encoding('ASCII-8BIT')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment