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
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
......
......@@ -512,7 +512,7 @@ module ApplicationHelper
end
def anchor(text)
text.to_s.gsub(' ', '_')
text.to_s.tr(' ', '_')
end
def html_hours(text)
......
......@@ -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|
......
......@@ -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
......
......@@ -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}",
......
......@@ -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)
......
......@@ -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')
......
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