diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-27 02:15:24 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-27 02:15:24 +0000 |
commit | 72e1451159206af1c335b23e0c1e5bf9ed84bc85 (patch) | |
tree | 598902ed0066c4b292a6c1612aad4b203cbb81de /app/models/attachment.rb | |
parent | f0d579adebfe3c5da93135fbaa3d9ec503d06855 (diff) | |
download | redmine-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/attachment.rb')
-rw-r--r-- | app/models/attachment.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index a4870e380..45560d0dc 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -245,7 +245,7 @@ class Attachment < ActiveRecord::Base end def is_diff? - self.filename =~ /\.(patch|diff)$/i + /\.(patch|diff)$/i.match?(filename) end def is_pdf? @@ -494,7 +494,7 @@ class Attachment < ActiveRecord::Base def self.disk_filename(filename, directory=nil) timestamp = DateTime.now.strftime("%y%m%d%H%M%S") ascii = '' - if filename =~ %r{^[a-zA-Z0-9_\.\-]*$} && filename.length <= 50 + if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50 ascii = filename else ascii = Digest::MD5.hexdigest(filename) |