Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change ForceSSLHandler#secure? to use == instead of regex
It's more clear and 52x faster in majority of scenarios (matches) and 24x faster on redirects (mismatches) It also does remove case insensitive searching, but it discussion on the PR #1662 stated this should be okay functionality to change Benchmark: ```crystal require "benchmark" puts "Matches" Benchmark.ips do |x| x.report("String ==") do "https" == "https" end x.report("!! String =~ /https/i") do !!("https" =~ /https/i) end end puts "\n\nMismatches" Benchmark.ips do |x| x.report("String == mismatch") do "http" == "https" end x.report("!! String =~ /https/i mismatch") do !!("http" =~ /https/i) end end ``` ```plaintext ➜ tmp crystal build --release downcase-includes-vs-regex.cr && ./downcase-includes-vs-regex Matches String == 897.53M ( 1.11ns) (± 6.76%) 0.0B/op fastest !! String =~ /https/i 17.13M ( 58.36ns) (±16.32%) 16.0B/op 52.38× slower Mismatches String == mismatch 881.32M ( 1.13ns) (± 8.78%) 0.0B/op fastest !! String =~ /https/i mismatch 36.42M ( 27.46ns) (± 1.47%) 16.0B/op 24.20× slower ```
- Loading branch information