Actions
Patch #40010
closedReplace regular expression matches with String#start_with? / end_with?
Description
The attached patch replaces regular expression matches with String#start_with?
and String#end_with?
.
The change improves the efficiency and readability of the code.
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22] Warming up -------------------------------------- '#123'.start_with?('#') 2.218M i/100ms /^#/.match?('#123') 1.322M i/100ms Calculating ------------------------------------- '#123'.start_with?('#') 22.494M (± 1.0%) i/s - 113.141M in 5.030336s /^#/.match?('#123') 13.208M (± 0.8%) i/s - 66.089M in 5.003943s Comparison: '#123'.start_with?('#'): 22494308.6 i/s /^#/.match?('#123'): 13208263.3 i/s - 1.70x slower
Files
Actions