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
|
@ -396,8 +396,8 @@ class FeedManager
|
|||
|
||||
active_filters.map! do |filter|
|
||||
if filter.whole_word
|
||||
sb = filter.phrase =~ /\A[[:word:]]/ ? '\b' : ''
|
||||
eb = filter.phrase =~ /[[:word:]]\z/ ? '\b' : ''
|
||||
sb = /\A[[:word:]]/.match?(filter.phrase) ? '\b' : ''
|
||||
eb = /[[:word:]]\z/.match?(filter.phrase) ? '\b' : ''
|
||||
|
||||
/(?mix:#{sb}#{Regexp.escape(filter.phrase)}#{eb})/
|
||||
else
|
||||
|
@ -417,7 +417,7 @@ class FeedManager
|
|||
status.media_attachments.map(&:description).join("\n\n"),
|
||||
].compact.join("\n\n")
|
||||
|
||||
!combined_regex.match(combined_text).nil?
|
||||
combined_regex.match?(combined_text)
|
||||
end
|
||||
|
||||
# Adds a status to an account's feed, returning true if a status was
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue