summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-03-27 02:15:24 +0000
committerGo MAEDA <maeda@farend.jp>2019-03-27 02:15:24 +0000
commit72e1451159206af1c335b23e0c1e5bf9ed84bc85 (patch)
tree598902ed0066c4b292a6c1612aad4b203cbb81de /app/models/repository.rb
parentf0d579adebfe3c5da93135fbaa3d9ec503d06855 (diff)
downloadredmine-72e1451159206af1c335b23e0c1e5bf9ed84bc85.tar.gz
redmine-72e1451159206af1c335b23e0c1e5bf9ed84bc85.zip
Use Regexp#match? to reduce allocations of MatchData object (#28940).
Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@18011 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index f44c02f50..4331ae21d 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -149,7 +149,7 @@ class Repository < ActiveRecord::Base
end
def self.find_by_identifier_param(param)
- if param.to_s =~ /^\d+$/
+ if /^\d+$/.match?(param.to_s)
find_by_id(param)
else
find_by_identifier(param)
@@ -248,7 +248,7 @@ class Repository < ActiveRecord::Base
def find_changeset_by_name(name)
return nil if name.blank?
s = name.to_s
- if s.match(/^\d*$/)
+ if /^\d*$/.match?(s)
changesets.find_by(:revision => s)
else
changesets.where("revision LIKE ?", s + '%').first
@@ -469,7 +469,7 @@ class Repository < ActiveRecord::Base
regexp = Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"]
if changes[attribute] && regexp.present?
regexp = regexp.to_s.strip.gsub('%project%') {Regexp.escape(project.try(:identifier).to_s)}
- unless send(attribute).to_s.match(Regexp.new("\\A#{regexp}\\z"))
+ unless Regexp.new("\\A#{regexp}\\z").match?(send(attribute).to_s)
errors.add(attribute, :invalid)
end
end