lib/rubocop/cop/performance/start_with.rb in rubocop-performance-1.20.2 vs lib/rubocop/cop/performance/start_with.rb in rubocop-performance-1.21.0
- old
+ new
@@ -54,10 +54,11 @@
RESTRICT_ON_SEND = %i[match =~ match?].freeze
def_node_matcher :redundant_regex?, <<~PATTERN
{(call $!nil? {:match :=~ :match?} (regexp (str $#literal_at_start?) (regopt)))
(send (regexp (str $#literal_at_start?) (regopt)) {:match :match?} $_)
- (match-with-lvasgn (regexp (str $#literal_at_start?) (regopt)) $_)}
+ (match-with-lvasgn (regexp (str $#literal_at_start?) (regopt)) $_)
+ (send (regexp (str $#literal_at_start?) (regopt)) :=~ $_)}
PATTERN
def on_send(node)
return unless (receiver, regex_str = redundant_regex?(node))