Optimize some regex matching (#15528)
* Use Regex#match? * Replace =~ too * Avoid to call match? from Nil * Keep value of Regexp.last_match
This commit is contained in:
parent
7d0031a515
commit
eb51e43fb4
13 changed files with 20 additions and 20 deletions
|
@ -28,9 +28,9 @@ class Sanitize
|
|||
return unless class_list
|
||||
|
||||
class_list.keep_if do |e|
|
||||
next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes
|
||||
next true if e =~ /^(mention|hashtag)$/ # semantic classes
|
||||
next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes
|
||||
next true if /^(h|p|u|dt|e)-/.match?(e) # microformats classes
|
||||
next true if /^(mention|hashtag)$/.match?(e) # semantic classes
|
||||
next true if /^(ellipsis|invisible)$/.match?(e) # link formatting classes
|
||||
end
|
||||
|
||||
node['class'] = class_list.join(' ')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue