Patch #34150

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

Added by Go MAEDA about 1 month ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Performance
Target version:4.2.0

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

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


Related issues

Related to Redmine - Feature #34142: Drop Ruby 2.3 support Closed
Blocks Redmine - Patch #32530: Update RuboCop to 1.0 Closed

Associated revisions

Revision 20168
Added by Go MAEDA about 1 month ago

Use match? instead of =~ when MatchData is not used (#34150).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA about 1 month ago

#2 Updated by Go MAEDA about 1 month ago

#3 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch.

Also available in: Atom PDF