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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor I18n.normalize_keys improvement #616

Merged
merged 1 commit into from Feb 3, 2022

Commits on Feb 3, 2022

  1. Tweak array construction in normalize_keys

    This results in a performance increase, and reduced object allocation, when normalizing keys -
    
    ```ruby
    report = Benchmark.ips do |x|
      x.report("concat") do
        ex = []
        ex.concat ['foo']
        ex.concat ['bar', 'baz']
        ex.concat ['quix']
        ex
      end
      x.report("splat") do
        [
          *['foo'],
          *['bar', 'baz'],
          *['quix']
        ]
      end
      x.compare!
    Warming up --------------------------------------
                  concat   129.103k i/100ms
                   splat   243.963k i/100ms
    Calculating -------------------------------------
                  concat      1.176M (卤 9.7%) i/s -      5.810M in   5.009251s
                   splat      2.435M (卤11.8%) i/s -     11.954M in   5.019257s
    
    Comparison:
                   splat:  2434746.6 i/s
                  concat:  1176432.3 i/s - 2.07x  (卤 0.00) slower
    ```
    codealchemy committed Feb 3, 2022
    Copy the full SHA
    f3c1936 View commit details
    Browse the repository at this point in the history