From eb51e43fb4386120f77f2ff99581f15018a81bd4 Mon Sep 17 00:00:00 2001 From: luigi <007.lva@gmail.com> Date: Fri, 22 Jan 2021 04:09:08 -0500 Subject: Optimize some regex matching (#15528) * Use Regex#match? * Replace =~ too * Avoid to call match? from Nil * Keep value of Regexp.last_match --- app/lib/sanitize_config.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/lib/sanitize_config.rb') diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index 8f700197b..a2e1d9d01 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -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(' ') -- cgit