mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Replace certain uses of 'gsub' with 'tr' or 'chomp' for a speed
improvement
This commit is contained in:
@ -94,12 +94,12 @@ module Email
|
||||
|
||||
# http://www.ietf.org/rfc/rfc2919.txt
|
||||
if topic && topic.category && !topic.category.uncategorized?
|
||||
list_id = "<#{topic.category.name.downcase.gsub(' ', '-')}.#{host}>"
|
||||
list_id = "<#{topic.category.name.downcase.tr(' ', '-')}.#{host}>"
|
||||
|
||||
# subcategory case
|
||||
if !topic.category.parent_category_id.nil?
|
||||
parent_category_name = Category.find_by(id: topic.category.parent_category_id).name
|
||||
list_id = "<#{topic.category.name.downcase.gsub(' ', '-')}.#{parent_category_name.downcase.gsub(' ', '-')}.#{host}>"
|
||||
list_id = "<#{topic.category.name.downcase.tr(' ', '-')}.#{parent_category_name.downcase.tr(' ', '-')}.#{host}>"
|
||||
end
|
||||
else
|
||||
list_id = "<#{host}>"
|
||||
|
@ -16,7 +16,7 @@ class IPAddr
|
||||
(4 - parts.size).times { parts << '*' } # support strings like 192.*
|
||||
v = parts.join('.')
|
||||
|
||||
"#{v.gsub('*', '0')}/#{32 - (v.count('*') * 8)}"
|
||||
"#{v.tr('*', '0')}/#{32 - (v.count('*') * 8)}"
|
||||
end
|
||||
|
||||
def to_cidr_s
|
||||
|
@ -20,9 +20,9 @@ module Slug
|
||||
private
|
||||
|
||||
def self.ascii_generator(string)
|
||||
string.gsub("'", "")
|
||||
string.tr("'", "")
|
||||
.parameterize
|
||||
.gsub("_", "-")
|
||||
.tr("_", "-")
|
||||
end
|
||||
|
||||
def self.encoded_generator(string)
|
||||
|
Reference in New Issue
Block a user