Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This matters since there are quite a few public methods per cop class. In total, it gets called ~57k times, or ~104 times per cop class. `method_defined?` is faster than string checking, so move that first. It also eliminates most of the checks, Base contains 98 methods. Current: ``` $ hyperfine -w 10 -r 25 "bundle exec rubocop Rakefile --cache=false" Benchmark 1: bundle exec rubocop Rakefile --cache=false Time (mean ± σ): 932.8 ms ± 7.6 ms [User: 828.0 ms, System: 104.0 ms] Range (min … max): 919.5 ms … 952.2 ms 25 runs ``` With String: ``` $ hyperfine -w 10 -r 25 "bundle exec rubocop Rakefile --cache=false" Benchmark 1: bundle exec rubocop Rakefile --cache=false Time (mean ± σ): 924.1 ms ± 7.8 ms [User: 816.3 ms, System: 107.3 ms] Range (min … max): 912.8 ms … 941.5 ms 25 runs ``` With String + order switched: ``` $ hyperfine -w 10 -r 25 "bundle exec rubocop Rakefile --cache=false" Benchmark 1: bundle exec rubocop Rakefile --cache=false Time (mean ± σ): 920.7 ms ± 6.9 ms [User: 814.5 ms, System: 105.6 ms] Range (min … max): 906.9 ms … 932.5 ms 25 runs ``` ~ 1.3% faster
- Loading branch information