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

Prevent warnings and errors when setting Mash keys more than once #415

Merged
merged 2 commits into from Feb 24, 2017

Commits on Feb 24, 2017

  1. Copy the full SHA
    9f77380 View commit details
    Browse the repository at this point in the history
  2. Don't log when overwriting Mash keys

    When we switched to using `#respond_to?` to detecting whether to log
    a Mash collision, we started reporting when we were overwriting keys
    that already exist in the Mash. This is a poor experience because it
    causes extra warnings (as in hashie#414) or, in the worst case, causes an
    "undefined method" error (as in hashie#413).
    
    This change fixes that problem and benchmarks to ensure we're not
    appreciably regressing performance. The results of two benchmarks are
    below:
    
    ```
    bundle exec ruby benchmark/mash_method_access.rb:
    
    Warming up --------------------------------------
      before    92.456k i/100ms
    Calculating -------------------------------------
      before      1.290M (± 4.4%) i/s -      6.472M in   5.028183s
    
    Pausing here -- run Ruby again to measure the next benchmark...
    
    Warming up --------------------------------------
        after    92.941k i/100ms
    Calculating -------------------------------------
        after      1.326M (± 5.4%) i/s -      6.692M in   5.060756s
    
    Comparison:
       after:  1326239.2 i/s
      before:  1289624.0 i/s - same-ish: difference falls within error
    ```
    
    and
    
    ```
    within spec/integrations/omniauth,
    bundle exec rake perf:ips
    
    Warming up --------------------------------------
      before     1.260k i/100ms
    Calculating -------------------------------------
      before     13.114k (± 4.2%) i/s -     66.780k in   5.101689s
    
    Pausing here -- run Ruby again to measure the next benchmark...
    
    Warming up --------------------------------------
        after     1.299k i/100ms
    Calculating -------------------------------------
        after     13.149k (± 4.0%) i/s -     66.249k in   5.046630s
    
    Comparison:
       after:    13148.9 i/s
      before:    13113.8 i/s - same-ish: difference falls within error
    ```
    
    Closes hashie#413
    Closes hashie#414
    michaelherold committed Feb 24, 2017
    Copy the full SHA
    55cfb8a View commit details
    Browse the repository at this point in the history