Project

General

Profile

Actions

Patch #34150

closed

Use match? instead of =~ when MatchData is not used

Added by Go MAEDA over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:

Description

String#match? was added in Ruby 2.4. you can replace =~ with faster String#match? or Regexp#match? when MatchData generated by `=~` is not necessary.

The attached patch changes such =~ to mach?. I generated the patch with the following commands.

sed -i '' 's/TargetRubyVersion: 2.3/TargetRubyVersion: 2.4/' .rubocop.yml 
bundle exec rubocop --only Performance/RegexpMatch -a

Files

use-match.diff (7.32 KB) use-match.diff Go MAEDA, 2020-10-22 04:17

Related issues

Related to Redmine - Feature #34142: Drop Ruby 2.3 supportClosedGo MAEDAActions
Blocks Redmine - Patch #32530: Update RuboCop to 1.12ClosedGo MAEDAActions
Actions

Also available in: Atom PDF