Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Performance/StringIdentifierArgument aware of string interpolation #387

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Make Performance/StringIdentifierArgument aware of string interpolation #387

merged 1 commit into from
Nov 21, 2023

Commits on Nov 21, 2023

  1. [Fix #386] Fix a false negative for `Performance/StringIdentifierArgu…

    …ment`
    
    Makes the cop aware of string interpolation.
    
    ```rb
    require 'benchmark/ips'
    
    puts `ruby -v`
    
    def foo_bar
    end
    
    bar = "bar"
    
    Benchmark.ips do |x|
      x.report('symbol arg') { send(:"foo_#{bar}") }
      x.report('string arg') { send("foo_#{bar}") }
    
      x.compare!
    end
    ```
    
    ```
    ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux-musl]
    Warming up --------------------------------------
              symbol arg   641.253k i/100ms
              string arg   602.373k i/100ms
    Calculating -------------------------------------
              symbol arg      6.385M (± 0.6%) i/s -     32.063M in   5.022123s
              string arg      6.023M (± 0.5%) i/s -     30.119M in   5.000717s
    
    Comparison:
              symbol arg:  6384545.4 i/s
              string arg:  6023007.5 i/s - 1.06x  slower
    ```
    Earlopain committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    1d7be50 View commit details
    Browse the repository at this point in the history